Total Complexity | 5 |
Total Lines | 61 |
Duplicated Lines | 0 % |
Coverage | 33.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
11 | class PhoneValidation extends Model |
||
12 | { |
||
13 | /** @var boolean */ |
||
14 | protected $ok; |
||
15 | |||
16 | /** @var String */ |
||
17 | protected $countryCode; |
||
18 | |||
19 | /** @var String */ |
||
20 | protected $nationalNumber; |
||
21 | |||
22 | /** |
||
23 | * parse |
||
24 | * |
||
25 | * @param array $data |
||
26 | * @author Tiago Araujo <[email protected]> |
||
27 | */ |
||
28 | 1 | public function parse(array $data) |
|
29 | { |
||
30 | 1 | $this->ok = (String)$data['ok']; |
|
|
|||
31 | 1 | $this->countryCode = (String)$data['country_code']; |
|
32 | 1 | $this->nationalNumber = (String)$data['national_number']; |
|
33 | 1 | } |
|
34 | |||
35 | /** |
||
36 | * toArray |
||
37 | * |
||
38 | * @return array |
||
39 | * @author Tiago Araujo <[email protected]> |
||
40 | */ |
||
41 | public function toArray(): array |
||
42 | { |
||
43 | return [ |
||
44 | 'ok' => $this->ok, |
||
45 | 'country_code' => $this->countryCode, |
||
46 | 'national_number' => $this->nationalNumber, |
||
47 | ]; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return bool |
||
52 | */ |
||
53 | public function isOk(): bool |
||
54 | { |
||
55 | return $this->ok; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return String |
||
60 | */ |
||
61 | public function getCountryCode(): String |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @return String |
||
68 | */ |
||
69 | public function getNationalNumber(): String |
||
72 | } |
||
73 | |||
74 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.