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.

EmailField::setData()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 2
nop 1
crap 3
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
use Respect\Validation\Validator as v;
5
6
/**
7
 *
8
 * @author solvire <[email protected]>
9
 * @package DataFields
10
 * @namespace Solvire\API\Serializers\DataFields
11
 */
12
class EmailField extends DataField
13
{
14
15
    protected $cast = 'string';
16
17 2
    public function setData($data)
18
    {
19 2
        if (! is_string($data) || ! v::email()->validate($data))
20 2
            throw new \RuntimeException('EmailField data must be a valid representation of an email address : ' . $data . ' in ' . $this->name );
21
        
22 2
        $this->data = $data;
23 2
        return $this;
24
    }
25
26
    /**
27
     * This is a char so it will always be just a string
28
     */
29 2
    public function getData()
30
    {
31 2
        return (string) $this->data;
32
    }
33
}