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.

IPAddressField   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
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 24
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setData() 0 12 3
A getData() 0 4 1
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
use Solvire\API\Exceptions\InvalidParameterException;
5
6
/**
7
 * IP Address is stored as a binary structure.
8
 *
9
 *
10
 * @see http://php.net/manual/en/function.inet-pton.php
11
 * @see http://php.net/manual/en/function.inet-ntop.php
12
 * @author solvire <[email protected]>
13
 * @package DataFields
14
 * @namespace Solvire\API\Serializers\DataFields
15
 */
16
class IPAddressField extends DataField
17
{
18
19 1
    public function setData($data)
20
    {
21 1
        if (! is_string($data))
22 1
            throw new InvalidParameterException(__CLASS__ . ' data must be a string representation of an IP Address: ' . $data . ' in ' . $this->name );
23
        
24 1
        $this->data = inet_pton($data);
25
        
26 1
        if ($this->data === false)
27 1
            throw new InvalidParameterException(__CLASS__ . ' your string did not decode properly ');
28
        
29 1
        return $this;
30
    }
31
32
    /**
33
     * Return this data in readable form
34
     */
35 1
    public function getData()
36
    {
37 1
        return inet_ntop($this->data);
38
    }
39
}
40