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