| Conditions | 5 |
| Paths | 6 |
| Total Lines | 32 |
| Code Lines | 21 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 29 | public function parse($entry) { |
||
| 30 | $data = []; |
||
| 31 | $defaults = []; |
||
| 32 | $path = null; |
||
| 33 | |||
| 34 | if (is_array($entry)) { |
||
| 35 | if (array_key_exists('src', $entry)) { |
||
| 36 | $path = $entry['src']; |
||
| 37 | unset($entry['src']); |
||
| 38 | } |
||
| 39 | |||
| 40 | foreach ($entry as $field => $value) { |
||
| 41 | $defaults[$field] = $value; |
||
| 42 | } |
||
| 43 | } else { |
||
| 44 | $path = $entry; |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!$path) { |
||
| 48 | return $data; |
||
| 49 | } |
||
| 50 | |||
| 51 | $image = $this->factory->create($path); |
||
| 52 | |||
| 53 | $data = [ |
||
| 54 | 'src' => $image->src(), |
||
| 55 | 'srcset' => $image->srcset(), |
||
| 56 | 'sizes' => $image->sizes(), |
||
| 57 | ] + $defaults; |
||
| 58 | |||
| 59 | return $data; |
||
| 60 | } |
||
| 61 | |||
| 63 |