nstack-io /
php-sdk
| 1 | <?php |
||
| 2 | |||
| 3 | namespace NStack\Models; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Class PhoneValidation |
||
| 7 | * |
||
| 8 | * @package NStack\Models |
||
| 9 | * @author Tiago Araujo <[email protected]> |
||
| 10 | */ |
||
| 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']; |
|
|
0 ignored issues
–
show
|
|||
| 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 |
||
| 62 | { |
||
| 63 | return $this->countryCode; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return String |
||
| 68 | */ |
||
| 69 | public function getNationalNumber(): String |
||
| 70 | { |
||
| 71 | return $this->nationalNumber; |
||
| 72 | } |
||
| 73 | } |
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.