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.

PhoneField   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 36
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 8 3
A getData() 0 4 1
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
use Respect\Validation\Validator as v;
5
6
/**
7
 *
8
 * @author solvire <[email protected]>
9
 * @package DataFields
10
 * @namespace Solvire\API\Serializers\DataFields
11
 */
12
class PhoneField extends DataField
13
{
14
15
    /**
16
     *
17
     * @var string
18
     */
19
    protected $cast = 'string';
20
21
    /**
22
     * (non-PHPdoc)
23
     * 
24
     * @see \Solvire\API\Serializers\DataFields\DataField::setData()
25
     */
26 2
    public function setData($data)
27
    {
28 2
        if (! is_string($data) || ! v::phone()->validate($data))
29 2
            throw new \RuntimeException('PhoneNumberField data must be a valid representation of a phone number: ' . $data . ' in ' . $this->name );
30
        
31 2
        $this->data = $data;
32 2
        return $this;
33
    }
34
35
    /**
36
     * This is a char so it will always be just a string
37
     *
38
     * (non-PHPdoc)
39
     * 
40
     * @see \Solvire\API\Serializers\DataFields\DataField::getData()
41
     * @return string
42
     */
43 2
    public function getData()
44
    {
45 2
        return (string) $this->data;
46
    }
47
}
48