Total Complexity | 9 |
Total Lines | 78 |
Duplicated Lines | 0 % |
Coverage | 88.89% |
Changes | 0 |
1 | <?php |
||
16 | class BalanceSheetPage extends AbstractScraper |
||
17 | { |
||
18 | /** |
||
19 | * @var int |
||
20 | */ |
||
21 | protected $cif; |
||
22 | |||
23 | /** |
||
24 | * @var int |
||
25 | */ |
||
26 | protected $year; |
||
27 | |||
28 | /** |
||
29 | * CompanyPage constructor. |
||
30 | * @param int $cif |
||
31 | * @param int $year |
||
32 | */ |
||
33 | 2 | public function __construct($cif, $year) |
|
34 | { |
||
35 | 2 | $this->setCif($cif); |
|
36 | 2 | $this->setYear($year); |
|
37 | 2 | } |
|
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | 1 | protected function generateCrawler() |
|
43 | { |
||
44 | 1 | if (!Helper::validateCif($this->getCif())) { |
|
45 | throw new InvalidCifException(); |
||
46 | } |
||
47 | 1 | $year = intval($this->getYear()); |
|
48 | 1 | if ($year < 2000 or $year > date('Y')) { |
|
|
|||
49 | throw new InvalidArgumentException( |
||
50 | 'Year [' . $this->getYear() . '] is invalid' |
||
51 | ); |
||
52 | } |
||
53 | 1 | $crawler = $this->getClient()->request( |
|
54 | 1 | 'GET', |
|
55 | 'http://www.mfinante.gov.ro/infocodfiscal.html?' . |
||
56 | 1 | 'an=WEB_ONG_AN' . $year |
|
57 | 1 | . '&cod=' . $this->getCif() |
|
58 | 1 | . '&captcha=null' |
|
59 | 1 | . '&method.bilant=VIZUALIZARE' |
|
60 | ); |
||
61 | 1 | return $crawler; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return int |
||
66 | */ |
||
67 | 1 | public function getCif() |
|
68 | { |
||
69 | 1 | return $this->cif; |
|
70 | } |
||
71 | |||
72 | /** |
||
73 | * @param int $cif |
||
74 | */ |
||
75 | 2 | public function setCif($cif) |
|
76 | { |
||
77 | 2 | $this->cif = $cif; |
|
78 | 2 | } |
|
79 | |||
80 | /** |
||
81 | * @return int |
||
82 | */ |
||
83 | 2 | public function getYear(): int |
|
86 | } |
||
87 | |||
88 | /** |
||
89 | * @param int $year |
||
90 | */ |
||
91 | 2 | public function setYear(int $year) |
|
94 | 2 | } |
|
95 | } |
||
96 |
PHP has two types of connecting operators (logical operators, and boolean operators):
and
&&
or
||
The difference between these is the order in which they are executed. In most cases, you would want to use a boolean operator like
&&
, or||
.Let’s take a look at a few examples:
Logical Operators are used for Control-Flow
One case where you explicitly want to use logical operators is for control-flow such as this:
Since
die
introduces problems of its own, f.e. it makes our code hardly testable, and prevents any kind of more sophisticated error handling; you probably do not want to use this in real-world code. Unfortunately, logical operators cannot be combined withthrow
at this point:These limitations lead to logical operators rarely being of use in current PHP code.