Conditions | 5 |
Paths | 3 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 7 |
CRAP Score | 5.2742 |
Changes | 0 |
1 | <?php |
||
23 | 42 | public function __construct($type, $id = null, $url = null) |
|
24 | { |
||
25 | 42 | $this->type = $type; |
|
26 | 42 | $this->id = $id; |
|
27 | 42 | $this->url = $url; |
|
28 | |||
29 | 42 | if ($type == self::TYPE_CUSTOM && !$url) { |
|
|
|||
30 | throw new \UnexpectedValueException('Please set url for custom counter'); |
||
31 | } |
||
32 | |||
33 | 42 | if ($type != self::TYPE_CUSTOM && !$id) { |
|
34 | throw new \UnexpectedValueException('Please set id for non custom counter'); |
||
35 | } |
||
36 | 42 | } |
|
37 | |||
55 | } |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: