@@ -85,7 +85,7 @@ |
||
| 85 | 85 | public function getText(string $selector): ?string |
| 86 | 86 | { |
| 87 | 87 | $attribute = null; |
| 88 | - $selector = preg_replace_callback('/\{(.*?)\}$/', function ($matches) use (&$attribute) { |
|
| 88 | + $selector = preg_replace_callback('/\{(.*?)\}$/', function($matches) use (&$attribute) { |
|
| 89 | 89 | if (count($matches) > 1) |
| 90 | 90 | { |
| 91 | 91 | $attribute = $matches[1]; |
@@ -41,8 +41,9 @@ |
||
| 41 | 41 | $this->cssFilters = []; |
| 42 | 42 | foreach ($cssFilters as $filter) |
| 43 | 43 | { |
| 44 | - if (!class_exists($filter) || !in_array(CssFilters\ICssFilter::class, class_implements($filter))) |
|
| 45 | - throw new \ErrorException("All CssFilters should implement ICssFilter, '$filter' does not."); |
|
| 44 | + if (!class_exists($filter) || !in_array(CssFilters\ICssFilter::class, class_implements($filter))) { |
|
| 45 | + throw new \ErrorException("All CssFilters should implement ICssFilter, '$filter' does not."); |
|
| 46 | + } |
|
| 46 | 47 | |
| 47 | 48 | $this->cssFilters[$filter::getFunctionName()] = $filter; |
| 48 | 49 | } |
@@ -31,7 +31,7 @@ |
||
| 31 | 31 | $functions[] = new $cssFilters[$func['function']](preg_split('/\s*,\s*/', $func['data'])); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - $selector['functions'] = $functions; |
|
| 34 | + $selector['functions'] = $functions; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | $result[] = $selector; |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | $functions = []; |
| 26 | 26 | foreach ($selector['functions'] as $func) |
| 27 | 27 | { |
| 28 | - if (!array_key_exists($func['function'], $cssFilters)) |
|
| 29 | - throw new \ErrorException('No CssFilter class found for \':' . $func['function'] . '\'.'); |
|
| 28 | + if (!array_key_exists($func['function'], $cssFilters)) { |
|
| 29 | + throw new \ErrorException('No CssFilter class found for \':' . $func['function'] . '\'.'); |
|
| 30 | + } |
|
| 30 | 31 | |
| 31 | 32 | $functions[] = new $cssFilters[$func['function']](preg_split('/\s*,\s*/', $func['data'])); |
| 32 | 33 | } |
@@ -56,14 +57,14 @@ discard block |
||
| 56 | 57 | for ($i = 0; $i < strlen($line); $i++) |
| 57 | 58 | { |
| 58 | 59 | $char = $line[$i]; |
| 59 | - if (empty(trim($char)) && empty(trim($selec))) |
|
| 60 | - continue; |
|
| 60 | + if (empty(trim($char)) && empty(trim($selec))) { |
|
| 61 | + continue; |
|
| 62 | + } |
|
| 61 | 63 | |
| 62 | 64 | if ($char !== ':') |
| 63 | 65 | { |
| 64 | 66 | $selec .= $char; |
| 65 | - } |
|
| 66 | - else |
|
| 67 | + } else |
|
| 67 | 68 | { |
| 68 | 69 | do |
| 69 | 70 | { |
@@ -72,8 +73,9 @@ discard block |
||
| 72 | 73 | for (++$i; $i < strlen($line); $i++) |
| 73 | 74 | { |
| 74 | 75 | $char = $line[$i]; |
| 75 | - if ($char === '(') |
|
| 76 | - break; |
|
| 76 | + if ($char === '(') { |
|
| 77 | + break; |
|
| 78 | + } |
|
| 77 | 79 | |
| 78 | 80 | $func .= $char; |
| 79 | 81 | } |
@@ -83,8 +85,9 @@ discard block |
||
| 83 | 85 | for ($i; $i < strlen($line); $i++) |
| 84 | 86 | { |
| 85 | 87 | $char = $line[$i]; |
| 86 | - if ($char === ')') |
|
| 87 | - break; |
|
| 88 | + if ($char === ')') { |
|
| 89 | + break; |
|
| 90 | + } |
|
| 88 | 91 | |
| 89 | 92 | $data .= $char; |
| 90 | 93 | } |
@@ -101,8 +104,9 @@ discard block |
||
| 101 | 104 | } |
| 102 | 105 | } |
| 103 | 106 | |
| 104 | - if (!empty(trim($selec))) |
|
| 105 | - $parts[] = ['selector' => $selec, 'functions' => $funcs]; |
|
| 107 | + if (!empty(trim($selec))) { |
|
| 108 | + $parts[] = ['selector' => $selec, 'functions' => $funcs]; |
|
| 109 | + } |
|
| 106 | 110 | |
| 107 | 111 | return $parts; |
| 108 | 112 | |
@@ -18,8 +18,7 @@ |
||
| 18 | 18 | if ($crawler->count() === 0) |
| 19 | 19 | { |
| 20 | 20 | return null; |
| 21 | - } |
|
| 22 | - else |
|
| 21 | + } else |
|
| 23 | 22 | { |
| 24 | 23 | return $crawler->first(); |
| 25 | 24 | } |
@@ -21,13 +21,15 @@ |
||
| 21 | 21 | function filterNodes(Crawler $crawler): ?Crawler { |
| 22 | 22 | |
| 23 | 23 | // Nth needs one parameter |
| 24 | - if (count($this->parameters) === 0) |
|
| 25 | - throw new \ErrorException(':nth(x) css selector should have at least one parameter'); |
|
| 24 | + if (count($this->parameters) === 0) { |
|
| 25 | + throw new \ErrorException(':nth(x) css selector should have at least one parameter'); |
|
| 26 | + } |
|
| 26 | 27 | |
| 27 | 28 | // If not enough nodes in the list, return null |
| 28 | 29 | $count = intval($this->parameters[0]); |
| 29 | - if ($crawler->count() < $count) |
|
| 30 | - return null; |
|
| 30 | + if ($crawler->count() < $count) { |
|
| 31 | + return null; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | // Get the nth element |
| 33 | 35 | return $crawler->eq($count - 1); |