Laravel 13 + Filament 5 admin panel and REST API for a non-profit developer collective, backed by the Pireon OAuth identity server. The public site is a separate, server-rendered application consuming /api/public/v1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
72 lines
2.3 KiB
PHP
72 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services\Git;
|
|
|
|
use Carbon\CarbonImmutable;
|
|
|
|
/**
|
|
* A provider-neutral picture of a repository at one moment in time.
|
|
*
|
|
* Every driver returns one of these, so the models, jobs and UI never learn
|
|
* the shape of any particular provider's JSON.
|
|
*/
|
|
final readonly class RepositorySnapshot
|
|
{
|
|
public function __construct(
|
|
public string $fullName,
|
|
public ?string $htmlUrl = null,
|
|
public ?string $description = null,
|
|
public ?string $homepage = null,
|
|
public ?string $defaultBranch = null,
|
|
public ?string $primaryLanguage = null,
|
|
public ?string $license = null,
|
|
/** @var array<int, string> */
|
|
public array $topics = [],
|
|
/** @var array<string, int> Bytes of code per language. */
|
|
public array $languages = [],
|
|
public int $stars = 0,
|
|
public int $forks = 0,
|
|
public int $watchers = 0,
|
|
public int $openIssuesCount = 0,
|
|
public int $contributorsCount = 0,
|
|
public int $commitsLastYear = 0,
|
|
public bool $isArchived = false,
|
|
public bool $isFork = false,
|
|
public ?CarbonImmutable $pushedAt = null,
|
|
public ?CarbonImmutable $createdAt = null,
|
|
/** @var array<int, IssueSnapshot> */
|
|
public array $issues = [],
|
|
) {}
|
|
|
|
/**
|
|
* The columns this snapshot writes onto a Repository model.
|
|
*
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toAttributes(): array
|
|
{
|
|
return [
|
|
'html_url' => $this->htmlUrl,
|
|
'description' => $this->description,
|
|
'homepage' => $this->homepage,
|
|
'default_branch' => $this->defaultBranch,
|
|
'primary_language' => $this->primaryLanguage,
|
|
'license' => $this->license,
|
|
'topics' => $this->topics,
|
|
'languages' => $this->languages,
|
|
'stars' => $this->stars,
|
|
'forks' => $this->forks,
|
|
'watchers' => $this->watchers,
|
|
'open_issues_count' => $this->openIssuesCount,
|
|
'contributors_count' => $this->contributorsCount,
|
|
'commits_last_year' => $this->commitsLastYear,
|
|
'is_archived' => $this->isArchived,
|
|
'is_fork' => $this->isFork,
|
|
'pushed_at' => $this->pushedAt,
|
|
'repo_created_at' => $this->createdAt,
|
|
];
|
|
}
|
|
}
|