| Conditions | 4 |
| Paths | 3 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 30 | public function scrape($content) |
||
| 31 | { |
||
| 32 | $paths = []; |
||
| 33 | $masks = []; |
||
| 34 | $matches = []; |
||
| 35 | preg_match_all( |
||
| 36 | '/srcset=*\s?=\s?([\'"])(.*?)([\'"])/i', |
||
| 37 | $content, |
||
| 38 | $matches |
||
| 39 | ); |
||
| 40 | |||
| 41 | foreach ($matches[2] as $mkey => $path) { |
||
| 42 | if (strpos($path, ',') === false) { |
||
| 43 | $paths[] = $path; |
||
| 44 | $masks[] = $matches[1][$mkey]; |
||
| 45 | continue; |
||
| 46 | } |
||
| 47 | |||
| 48 | $expPaths = explode(',', $path); |
||
| 49 | |||
| 50 | foreach ($expPaths as $singlePath) { |
||
| 51 | $paths[] = trim(str_replace(' 2x','', $singlePath)); |
||
| 52 | $masks[] = ''; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | return $this->assetFactory->createAssetsFromPaths($paths, $masks); |
||
| 57 | } |
||
| 58 | } |