GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PhoneValidation   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Test Coverage

Coverage 33.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 61
ccs 5
cts 15
cp 0.3333
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCountryCode() 0 3 1
A parse() 0 5 1
A toArray() 0 6 1
A getNationalNumber() 0 3 1
A isOk() 0 3 1
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
Documentation Bug introduced by
The property $ok was declared of type boolean, but (string)$data['ok'] is of type string. Maybe add a type cast?

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.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
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
}