| @@ 29-43 (lines=15) @@ | ||
| 26 | $this->timezone = $timezone; |
|
| 27 | } |
|
| 28 | ||
| 29 | public function parse(DOMDocument $dom, DOMXPath $xpath) : DateTimeImmutable |
|
| 30 | { |
|
| 31 | $closingDateHolder = $xpath->query('//div[./div/span[contains(text(), "CfS closes at")]]'); |
|
| 32 | ||
| 33 | if (! $closingDateHolder || $closingDateHolder->length == 0) { |
|
| 34 | throw new InvalidArgumentException('The CfP does not seem to have a closing date'); |
|
| 35 | } |
|
| 36 | ||
| 37 | $closingDay = $closingDateHolder->item(0)->getElementsByTagName('h2')->item(0)->textContent; |
|
| 38 | $closingHour = $closingDateHolder->item(0)->getElementsByTagName('span')->item(0)->textContent; |
|
| 39 | ||
| 40 | $closingHour = $this->clearClosingHour($closingHour); |
|
| 41 | ||
| 42 | return new DateTimeImmutable($closingDay . ' ' . $closingHour, $this->timezone); |
|
| 43 | } |
|
| 44 | ||
| 45 | private function clearClosingHour(string $closingHour) : string |
|
| 46 | { |
|
| @@ 31-45 (lines=15) @@ | ||
| 28 | $this->timezone = $timezone; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function parse(DOMDocument $dom, DOMXPath $xpath) : DateTimeImmutable |
|
| 32 | { |
|
| 33 | $openingDateHolder = $xpath->query('//div[./div/span[contains(text(), "' . self::OPENING_STRING . '")]]'); |
|
| 34 | ||
| 35 | if (! $openingDateHolder || $openingDateHolder->length == 0) { |
|
| 36 | throw new InvalidArgumentException('No CfP-Open Date found'); |
|
| 37 | } |
|
| 38 | ||
| 39 | $openingDay = $openingDateHolder->item(0)->getElementsByTagName('h2')->item(0)->textContent; |
|
| 40 | $openingHour = $openingDateHolder->item(0)->getElementsByTagName('span')->item(0)->textContent; |
|
| 41 | ||
| 42 | $openingHour = $this->clearOpeningHour($openingHour); |
|
| 43 | ||
| 44 | return new DateTimeImmutable($openingDay. ' ' . $openingHour, $this->timezone); |
|
| 45 | } |
|
| 46 | ||
| 47 | private function clearOpeningHour(string $openingHour) : string |
|
| 48 | { |
|