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.

GenderField::setMaleValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
5
use Solvire\Utilities\GenderNormalizer as G;
6
/**
7
 *
8
 * @author solvire <[email protected]>
9
 * @package DataFields
10
 * @namespace Solvire\API\Serializers\DataFields
11
 */
12
class GenderField extends DataField
13
{
14
15
    /**
16
     *
17
     * @var string
18
     */
19
    protected $cast = 'string';
20
    
21
    protected $maleValue = 'male';
22
    
23
    protected $femaleValue = 'female';
24
    
25
    /**
26
     *
27
     * @param array $options
28
     */
29 1
    public function __construct($options=[])
30
    {
31
        // load up the format at creation time
32 1
        if(isset($options['maleValue']))
33 1
            $this->maleValue = $options['maleValue'];
34
35 1
        if(isset($options['femaleValue']))
36 1
            $this->femaleValue = $options['femaleValue'];
37
        
38 1
        parent::__construct($options);
39 1
    }
40
41
    /**
42
     * (non-PHPdoc)
43
     * 
44
     * @see \Solvire\API\Serializers\DataFields\DataField::setData()
45
     */
46 1
    public function setData($data)
47
    {
48 1
        if (! is_string($data))
49 1
            throw new \RuntimeException('GenderField data must be a valid representation of a normalized gender : ' . $data . ' in ' . $this->name );
50
        
51 1
        $gender = G::spot($data);
52
        
53 1
        if($gender === 'male')
54 1
            $this->data = $this->maleValue;
55 1
        elseif ($gender === 'female')
56 1
            $this->data = $this->femaleValue;
57
        
58
        
59 1
        return $this;
60
    }
61
62
    /**
63
     * This is a char so it will always be just a string
64
     *
65
     * (non-PHPdoc)
66
     * 
67
     * @see \Solvire\API\Serializers\DataFields\DataField::getData()
68
     * @return string
69
     */
70 1
    public function getData()
71
    {
72 1
        return $this->data;
73
    }
74
    
75 1
    public function setMaleValue($male)
76
    {
77 1
        $this->maleValue = $male;
78 1
    }
79
    
80 1
    public function setFemaleValue($female)
81
    {
82 1
        $this->femaleValue = $female;
83 1
    }
84
}
85