TwitterPlaceSerializer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 52
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A serialize() 0 7 1
A unserialize() 0 6 1
A canSerialize() 0 4 1
A canUnserialize() 0 4 1
A build() 0 4 1
1
<?php
2
3
namespace Twitter\Serializer;
4
5
use Assert\Assertion;
6
use Twitter\Object\TwitterPlace;
7
use Twitter\TwitterSerializable;
8
use Twitter\TwitterSerializer;
9
10
class TwitterPlaceSerializer implements TwitterSerializer
11
{
12
    /**
13
     * @param  TwitterSerializable $object
14
     * @return \stdClass
15
     */
16 6
    public function serialize(TwitterSerializable $object)
17
    {
18
        /* @var TwitterPlace $object */
19 6
        Assertion::true($this->canSerialize($object), 'object must be an instance of TwitterPlace');
20
21 3
        return new \stdClass();
22
    }
23
24
    /**
25
     * @param  \stdClass $obj
26
     * @param  array     $context
27
     * @return TwitterPlace
28
     */
29 6
    public function unserialize($obj, array $context = [])
30
    {
31 6
        Assertion::true($this->canUnserialize($obj), 'object is not unserializable');
32
33 3
        return TwitterPlace::create();
34
    }
35
36
    /**
37
     * @param  TwitterSerializable $object
38
     * @return boolean
39
     */
40 6
    public function canSerialize(TwitterSerializable $object)
41
    {
42 6
        return $object instanceof TwitterPlace;
43
    }
44
45
    /**
46
     * @param  \stdClass $object
47
     * @return boolean
48
     */
49 6
    public function canUnserialize($object)
50
    {
51 6
        return $object !== null;
52
    }
53
54
    /**
55
     * @return TwitterPlaceSerializer
56
     */
57 15
    public static function build()
58
    {
59 15
        return new self();
60
    }
61
}
62