Scraper   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 26
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A scrape() 0 13 1
1
<?php
2
3
namespace Pilipinews\Website\Bworld;
4
5
use Pilipinews\Common\Article;
6
use Pilipinews\Common\Interfaces\ScraperInterface;
7
use Pilipinews\Common\Scraper as AbstractScraper;
8
9
/**
10
 * Business World 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('script', '.td-post-share', '.td-post-source-tags', '.wp-caption-text');
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
        $this->remove($this->removables);
33
34
        $title = $this->title('.entry-title');
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