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.

DateField::setData()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
namespace Solvire\API\Serializers\DataFields;
3
4
use Carbon\Carbon;
5
6
/**
7
 *
8
 * @author solvire <[email protected]>
9
 * @package DataFields
10
 * @namespace Solvire\API\Serializers\DataFields
11
 */
12
class DateField extends DataField
13
{
14
15
    protected $cast = 'string';
16
17
    /**
18
     * default formatting of ISO8601
19
     *
20
     * @var string [Y-m-d\TH:i:sO]
21
     */
22
    protected $format = Carbon::ISO8601;
23
24
    /**
25
     * TODO this needs to handle timezones better.
26
     * we should check to make sure the wrong timezone isn't set or have some failsafes
27
     * the return type should be definable and it's not yet
28
     *
29
     * (non-PHPdoc)
30
     *
31
     * @see \Solvire\API\Serializers\DataFields\DataField::setData()
32
     * @param
33
     *            \DateTime
34
     */
35 1
    public function setData($data)
36
    {
37 1
        if (! ($data instanceof \DateTime))
38 1
            throw new \RuntimeException('DateField data must be a DateTime object: ' . $data . ' in ' . $this->name );
39 1
        $this->data = $data;
40 1
        return $this;
41
    }
42
43
    /**
44
     * This is a char so it will always be just a string
45
     *
46
     * @return Carbon or DateTime object
47
     */
48 1
    public function getData()
49
    {
50 1
        return $this->data;
51
    }
52
}