Test Failed
Push — master ( fa8c20...ab35ba )
by Nicolas
02:05
created

AbstractCpParser   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A loadContent() 0 9 2
1
<?php
2
3
namespace Cp\Parser;
4
5
use PHPHtmlParser\Dom;
6
7
/**
8
 * Class AbstractCpParser
9
 */
10
class AbstractCpParser
11
{
12
    /**
13
     * @var Dom
14
     */
15
    protected $parser;
16
17
    /**
18
     * CpParser constructor.
19
     *
20
     * @param Dom $parser
21
     */
22
    public function __construct(Dom $parser)
23
    {
24
        $this->parser = $parser;
25
    }
26
27
    /**
28
     * @param string $url
29
     *
30
     * @throws \Exception
31
     */
32
    public function loadContent($url)
33
    {
34
        $htmlContent = file_get_contents($url);
35
        if (false === $htmlContent) {
36
            throw new \Exception(sprintf('Content can not be get from %s', $url));
37
        }
38
39
        $this->parser->load($htmlContent);
40
    }
41
}