Completed
Push — master ( 7c13fc...e13714 )
by Gabriel
04:40
created

CompanyPage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 45
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A generateCrawler() 0 10 2
A getCif() 0 3 1
A setCif() 0 3 1
1
<?php
2
3
namespace ByTIC\MFinante\Scrapers;
4
5
use ByTIC\MFinante\Exception\InvalidCifException;
6
use ByTIC\MFinante\Helper;
7
use ByTIC\MFinante\Parsers\CompanyPage as Parser;
8
9
/**
10
 * Class CompanyPage
11
 * @package ByTIC\MFinante\Scrapers
12
 *
13
 * @method Parser execute()
14
 */
15
class CompanyPage extends AbstractScraper
16
{
17
    /**
18
     * @var int
19
     */
20
    protected $cif;
21
22
    /**
23
     * CompanyPage constructor.
24
     * @param int $cif
25
     */
26
    public function __construct($cif)
27
    {
28
        $this->setCif($cif);
29
    }
30
31
    /**
32
     * @return int
33
     */
34
    public function getCif()
35
    {
36
        return $this->cif;
37
    }
38
39
    /**
40
     * @param int $cif
41
     */
42
    public function setCif($cif)
43
    {
44
        $this->cif = $cif;
45
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50
    protected function generateCrawler()
51
    {
52
        if (!Helper::validateCif($this->getCif())) {
53
            throw new InvalidCifException();
54
        }
55
        $crawler = $this->getClient()->request(
56
            'GET',
57
            'http://www.mfinante.gov.ro/infocodfiscal.html?cod=' . $this->getCif()
58
        );
59
        return $crawler;
60
    }
61
}
62