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.

BooleanField::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
 *
8
 * @author solvire <[email protected]>
9
 * @package DataFields
10
 * @namespace Solvire\API\Serializers\DataFields
11
 */
12
class BooleanField extends DataField
13
{
14
15
    protected $cast = 'string';
16
17
    /**
18
     * TODO need to set the truthiness of this thing - true == TRUE == True == 1
19
     * (non-PHPdoc)
20
     * 
21
     * @see \Solvire\API\Serializers\DataFields\DataField::setData()
22
     */
23 1
    public function setData($data)
24
    {
25
        // a hack for right now. 
26
        // need a truthy table 
27 1
        if($data === '0' || $data === 0)
28 1
            $data = false;
29
        
30 1
        if($data === '1' || $data === 1)
31 1
            $data = true;
32
        
33 1
        if (! is_bool($data))
34 1
            throw new InvalidParameterException('BooleanField data must be a boolean: ' . $data . ' in ' . $this->name );
35
        
36 1
        $this->data = $data;
37 1
        return $this;
38
    }
39
40
    /**
41
     * This is a Boolean so it will always be just a boolean
42
     * TODO get the truthiness of this data
43
     * 
44
     * @return boolean
45
     */
46 1
    public function getData()
47
    {
48 1
        return (boolean) $this->data;
49
    }
50
}