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

CompanyPage::generateCrawler()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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