Scraper::scrape()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 13
rs 10
1
<?php
2
3
namespace Pilipinews\Website\Bmirror;
4
5
use Pilipinews\Common\Article;
6
use Pilipinews\Common\Interfaces\ScraperInterface;
7
use Pilipinews\Common\Scraper as AbstractScraper;
8
9
/**
10
 * Business Mirror 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('.td-a-rec', '.addtoany_share_save_container');
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((array) $this->removables);
35
36
        $body = $this->body('.tdb_single_content > .tdb-block-inner.td-fix-index');
37
38
        $html = $this->html($body);
39
40
        return new Article($title, $html, $link);
41
    }
42
}
43