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

AbstractCpParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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
}