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::getData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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