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.

PointField::setData()   B
last analyzed

Complexity

Conditions 5
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 7
nc 2
nop 1
crap 5
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
use Solvire\API\Exceptions\InvalidParameterException;
5
6
/**
7
 * Kind of a hack to couple the data elements in separate fields as a single point for representation
8
 * In GIS databases this would be one data element.
9
 *
10
 *
11
 * @author solvire <[email protected]>
12
 * @package DataFields
13
 * @namespace Solvire\API\Serializers\DataFields
14
 */
15
class PointField extends DataField
16
{
17
18
    protected $cast = 'array';
19
20 4
    public function __construct($options)
21
    {
22 4
        parent::__construct($options);
23 4
    }
24
25
    /**
26
     * (non-PHPdoc)
27
     *
28
     * @see \Solvire\API\Serializers\DataFields\DataField::setData()
29
     */
30 2
    public function setData($data)
31
    {
32 2
        if ((! is_array($data) || ! isset($data['latitude']) || ! isset($data['longitude'])) && ! $this->allowNull())
33 2
            throw new InvalidParameterException('PointField data must be an array of fields with keys of latitude and longitude');
34
            
35
            // keeping it clean
36
            // don't want other fields slipping in
37 2
        $this->data = [
38 2
            'latitude' => $data['latitude'],
39 2
            'longitude' => $data['longitude']
40 2
        ];
41 2
        return $this;
42
    }
43
44
    /**
45
     * This is a char so it will always be just a string
46
     */
47 2
    public function getData()
48
    {
49 2
        return $this->data;
50
    }
51
}
52