Completed
Push — master ( 841bb5...43701d )
by Nate
09:20
created

DeserializationContext   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 57
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getDepth() 0 4 1
A getName() 0 4 1
A allowMultiple() 0 4 1
1
<?php
2
/*
3
 * Copyright (c) Nate Brunette.
4
 * Distributed under the MIT License (http://opensource.org/licenses/MIT)
5
 */
6
 
7
namespace Tebru\Retrofit\Annotation\Serializer;
8
9
use Tebru\Dynamo\Annotation\DynamoAnnotation;
10
11
/**
12
 * DeserializationContext
13
 *
14
 * Define a context when deserializing an object from a response.
15
 *
16
 * @author Matthew Loberg <[email protected]>
17
 * @author Nate Brunette <[email protected]>
18
 *
19
 * @Annotation
20
 * @Target({"CLASS", "METHOD"})
21
 */
22
class DeserializationContext extends JmsSerializerContext implements DynamoAnnotation
23
{
24
    const NAME = 'deserialization_context';
25
26
    /**
27
     * Depth to use while deserializing
28
     *
29
     * @var int
30
     */
31
    private $depth;
32
33
    /**
34
     * Constructor
35
     *
36
     * @param array $params
37
     */
38
    public function __construct(array $params)
39
    {
40
        if (array_key_exists('depth', $params)) {
41
            $this->depth = $params['depth'];
42
            unset($params['depth']);
43
        }
44
45
        parent::__construct($params);
46
    }
47
48
    /**
49
     * Get Depth
50
     *
51
     * @return int
52
     */
53
    public function getDepth()
54
    {
55
        return $this->depth;
56
    }
57
58
    /**
59
     * The name of the annotation or class of annotations
60
     *
61
     * @return string
62
     */
63
    public function getName()
64
    {
65
        return self::NAME;
66
    }
67
68
    /**
69
     * Whether or not multiple annotations of this type can
70
     * be added to a method
71
     *
72
     * @return bool
73
     */
74
    public function allowMultiple()
75
    {
76
        return false;
77
    }
78
}
79