Conditions | 7 |
Paths | 5 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
17 | public function parse(DOMDocument $dom, DOMXPath $xpath) : string |
||
|
|||
18 | { |
||
19 | // This expression does not work. It looks like the reason is the array-notation... |
||
20 | //$locations = $xpath->query('//div[contains(text()[2], "location")]/following-sibling::h2/span'); |
||
21 | $locationMarker = $xpath->query("//div[contains(., 'location')]"); |
||
22 | if (! $locationMarker || $locationMarker->length == 0) { |
||
23 | throw new \InvalidArgumentException('The Event does not seem to have a locationMarker'); |
||
24 | } |
||
25 | |||
26 | $locations = $xpath->query('//h2/span', $locationMarker->item(0)->parentNode); |
||
27 | |||
28 | if (! $locations || $locations->length == 0) { |
||
29 | throw new \InvalidArgumentException('The Event does not seem to have a location'); |
||
30 | } |
||
31 | $location = []; |
||
32 | foreach ($locations as $item) { |
||
33 | $location = trim($item->textContent); |
||
34 | if ($location === '') { |
||
35 | continue; |
||
36 | } |
||
37 | |||
38 | return $location; |
||
39 | |||
40 | $location[] = $location; |
||
41 | } |
||
42 | |||
43 | return implode(', ', array_unique($location)); |
||
44 | } |
||
45 | } |
||
46 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.