'', 'full' => ''], array $tracks = [] ): self { return new self($url, $cover, $wiki, $tracks); } public static function fromLastFmData(object $data): self { return self::make( url: $data->url, cover: Arr::get($data->image, '0.#text'), wiki: [ 'summary' => isset($data->wiki) ? self::formatLastFmText($data->wiki->summary) : '', 'full' => isset($data->wiki) ? self::formatLastFmText($data->wiki->content) : '', ], tracks: array_map(static fn ($track): array => [ 'title' => $track->name, 'length' => (int) $track->duration, 'url' => $track->url, ], $data->tracks?->track ?? []), ); } /** @return array */ public function toArray(): array { return [ 'url' => $this->url, 'cover' => $this->cover, 'wiki' => $this->wiki, 'tracks' => $this->tracks, ]; } }