use PortalPeopleStatis\modules\SatisfyManager\models\RepositoryActiveRecord;
<?php
namespace PortalPeopleStatis\modules\SatisfyManager\repositories;

use Yiisoft\Db\Connection;
use PortalPeopleStatis\modules\SatisfyManager\models\Repository;

class RepositoryRepository
{
    private Connection $db;

    public function __construct(Connection $db)
    {
        $this->db = $db;
    }

    public function save(Repository $repo): bool
    {
        $record = new RepositoryActiveRecord($this->db);
        $record->setAttributes([
            'name' => $repo->name,
            'type' => $repo->type,
            'url' => $repo->url,
        ]);
        $record->save();
        return true;
    }

    public function findAll(): array
    {
        $rows = (new RepositoryActiveRecord($this->db))->find()->all();
        return array_map(fn($row) => new Repository($row), $rows);
    }
}
