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   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B setData() 0 16 6
A getData() 0 4 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
}