| Total Complexity | 4 |
| Total Lines | 57 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | class Crawler implements CrawlerInterface |
||
| 16 | { |
||
| 17 | /** |
||
| 18 | * @var string[] |
||
| 19 | */ |
||
| 20 | protected $allowed = array('news/nation', 'news/regions'); |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | protected $link = 'https://data.gmanetwork.com/gno/pages/home_1a_json.gz'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Returns an array of articles to scrape. |
||
| 29 | * |
||
| 30 | * @return string[] |
||
| 31 | */ |
||
| 32 | 3 | public function crawl() |
|
| 33 | { |
||
| 34 | 3 | $response = Client::request($this->link); |
|
| 35 | |||
| 36 | 3 | $json = json_decode($response, true); |
|
| 37 | |||
| 38 | 3 | $items = $json['story_lists_just_in']; |
|
| 39 | |||
| 40 | 3 | return $this->verify((array) $items); |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Returns the allowed article URLs to scrape. |
||
| 45 | * |
||
| 46 | * @param string[] $items |
||
| 47 | * @return string[] |
||
| 48 | */ |
||
| 49 | 3 | protected function verify($items) |
|
| 72 | } |
||
| 73 | } |
||
| 74 |