Scraper::scrape()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Pilipinews\Website\Mtimes;
4
5
use Pilipinews\Common\Article;
6
use Pilipinews\Common\Interfaces\ScraperInterface;
7
use Pilipinews\Common\Scraper as AbstractScraper;
8
9
/**
10
 * Manila Times Scraper
11
 *
12
 * @package Pilipinews
13
 * @author  Rougin Gutib <[email protected]>
14
 */
15
class Scraper extends AbstractScraper implements ScraperInterface
16
{
17
    /**
18
     * @var string[]
19
     */
20
    protected $removables = array('.tdb-sub-title', '.tdb-flex-min', '.breadcrumb', '.tdb-social-share', '.wp-caption', '.td-a-ad', 'style', 'script');
21
22
    /**
23
     * Returns the contents of an article.
24
     *
25
     * @param  string $link
26
     * @return \Pilipinews\Common\Article
27
     */
28
    public function scrape($link)
29
    {
30
        $this->prepare((string) $link);
31
32
        $title = $this->title('.tdb-title-text');
33
34
        $this->remove($this->removables);
35
36
        $body = $this->body('.td-post-content');
37
38
        $html = $this->html($body);
39
40
        return new Article($title, $html, $link);
41
    }
42
}
43