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