Conditions | 4 |
Paths | 2 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
104 | public static function fromApi(array $data): self |
||
105 | { |
||
106 | $images = []; |
||
107 | |||
108 | if (array_key_exists('image', $data)) { |
||
109 | foreach ((array) $data['image'] as $image) { |
||
110 | $images[] = new Image($image['#text']); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | return new self( |
||
115 | $data['name'], |
||
116 | $data['artist'] ? Artist::fromApi($data['artist']) : null, |
||
117 | $data['mbid'] ?? null, |
||
118 | $data['url'] ?? null, |
||
119 | $images |
||
120 | ); |
||
121 | } |
||
122 | } |
||
123 |