| Conditions | 3 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 5 |
| CRAP Score | 3.0416 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 38 | 10 | public function selectLink(string $search): Link |
|
| 39 | { |
||
| 40 | 10 | $elements = $this->crawler->filterXPath('//a')->reduce( |
|
| 41 | fn (Crawler $linkElement): bool => |
||
| 42 | 10 | ('' !== $text = $linkElement->text('')) && fnmatch($search, $text, FNM_CASEFOLD) |
|
| 43 | ); |
||
| 44 | |||
| 45 | 10 | if ($elements->count() > 0) { |
|
| 46 | 10 | return $elements->first()->link(); |
|
| 47 | } |
||
| 48 | |||
| 49 | throw new RuntimeException(sprintf('Link text "%s" was not found', $search)); |
||
| 50 | } |
||
| 52 |