aspirecloud/app/Values/WpOrg/Themes/ThemeUpdateCheckResponse.php
2025-10-25 13:15:51 -06:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Values\WpOrg\Themes;
use App\Models\WpOrg\Theme;
use App\Values\DTO;
use Illuminate\Support\Collection;
readonly class ThemeUpdateCheckResponse extends DTO
{
/**
* @param Collection<string, ThemeUpdateData> $themes
* @param Collection<string, ThemeUpdateData> $no_update
* @param Collection<array-key, mixed> $translations
*/
public function __construct(
public Collection $themes,
public Collection $no_update,
public Collection $translations,
) {}
/**
* @param iterable<array-key, Theme> $themes
* @param iterable<array-key, Theme> $no_update
*/
public static function fromResults(iterable $themes, iterable $no_update): self
{
$mkUpdates = fn(iterable $items) => ThemeUpdateData::collect($items)->keyBy('theme');
return new self(
themes: $mkUpdates($themes), // @mago-expect analysis:less-specific-argument
no_update: $mkUpdates($no_update), // @mago-expect analysis:less-specific-argument
translations: collect(), // TODO
);
}
}