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.

TimeZoneCustomSerializer::deserialize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 2
eloc 4
nc 2
nop 2
crap 2
1
<?php
2
3
namespace RemiSan\Serializer\CustomSerializer;
4
5
class TimeZoneCustomSerializer implements CustomSerializer
6
{
7
    /**
8
     * Serialize the object
9
     *
10
     * @param object $object
11
     *
12
     * @return array|void
13
     */
14 12
    public function serialize($object)
15
    {
16 12
        if (!$this->canHandle(get_class($object))) {
17 3
            throw new \InvalidArgumentException();
18
        }
19
20 9
        return [ $object->getName() ];
21
    }
22
23
    /**
24
     * Deserialize the object
25
     *
26
     * @param array  $serialized
27
     * @param string $fqcn the fully qualified class name
28
     *
29
     * @return object
30
     */
31 12
    public function deserialize(array $serialized, $fqcn)
32
    {
33 12
        if (!$this->canHandle($fqcn)) {
34 3
            throw new \InvalidArgumentException();
35
        }
36
37 9
        return new \DateTimeZone($serialized[0]);
38
    }
39
40
    /**
41
     * Can the custom serializer (de)serialize the objects of this class
42
     *
43
     * @param string $className
44
     *
45
     * @return boolean
46
     */
47 30
    public function canHandle($className)
48
    {
49 30
        return $className === \DateTimeZone::class;
50
    }
51
}
52