| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 21 | public function filterNodes(Crawler $crawler): ?Crawler |
||
| 22 | { |
||
| 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'); |
||
| 26 | } |
||
| 27 | |||
| 28 | // If not enough nodes in the list, return null |
||
| 29 | $count = intval($this->parameters[0]); |
||
| 30 | if ($crawler->count() < $count) { |
||
| 31 | return null; |
||
| 32 | } |
||
| 33 | |||
| 34 | // Get the nth element |
||
| 35 | return $crawler->eq($count - 1); |
||
| 36 | } |
||
| 38 |