| Conditions | 6 |
| Paths | 5 |
| Total Lines | 28 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function getReleaseDates(Movie $movie): array |
||
| 22 | { |
||
| 23 | if ($movie->getImdbId() === null) { |
||
| 24 | return []; |
||
| 25 | } |
||
| 26 | |||
| 27 | $html = $this->loadImdbReleaseDatesPageHtml($movie->getImdbId()); |
||
| 28 | $crawler = new Crawler($html, self::IMDB_RELEASE_DATES_URL); |
||
| 29 | |||
| 30 | $tds = $crawler->filterXPath('//*[@id="release_dates"]//td')->getIterator(); |
||
| 31 | |||
| 32 | $result = []; |
||
| 33 | $country = ''; |
||
| 34 | foreach ($tds as $td) { |
||
| 35 | if ($td->getAttribute('class') === 'release_date') { |
||
| 36 | $result[$country] = $this->imdbMapper->dateToObject($td->textContent); |
||
| 37 | continue; |
||
| 38 | } |
||
| 39 | |||
| 40 | if ($td->hasChildNodes() && $td->getElementsByTagName('a')->item(0) !== null) { |
||
| 41 | $country = $td->getElementsByTagName('a')->item(0)->textContent; |
||
| 42 | $country = $this->imdbMapper->countryToCode($country); |
||
| 43 | continue; |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | return $result; |
||
| 48 | } |
||
| 49 | |||
| 69 |