mirror of
https://github.com/ivuorinen/branch-usage-checker.git
synced 2026-02-25 10:52:28 +00:00
The spatie/data-transfer-object package is abandoned. Replace it with a native PHP 8.4 final readonly class using a static factory method, removing the dependency entirely.
34 lines
901 B
PHP
34 lines
901 B
PHP
<?php
|
|
|
|
namespace App\Dto;
|
|
|
|
final readonly class PackagistApiPackagePayload
|
|
{
|
|
public function __construct(
|
|
public string $name = '',
|
|
public string $description = '',
|
|
public string $time = '',
|
|
public array $versions = [],
|
|
public string $type = '',
|
|
public string $repository = '',
|
|
public string $language = '',
|
|
) {
|
|
}
|
|
|
|
/** Create from the raw Packagist API response array. */
|
|
public static function fromResponse(array $data): self
|
|
{
|
|
$pkg = $data['package'] ?? [];
|
|
|
|
return new self(
|
|
name: $pkg['name'] ?? '',
|
|
description: $pkg['description'] ?? '',
|
|
time: $pkg['time'] ?? '',
|
|
versions: $pkg['versions'] ?? [],
|
|
type: $pkg['type'] ?? '',
|
|
repository: $pkg['repository'] ?? '',
|
|
language: $pkg['language'] ?? '',
|
|
);
|
|
}
|
|
}
|