Completed
Pull Request — master (#11)
by Eric
04:22
created

XmlCollection::__construct()   B

Complexity

Conditions 6
Paths 32

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 17
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 17
cts 17
cp 1
rs 8.6737
c 0
b 0
f 0
cc 6
eloc 11
nc 32
nop 1
crap 6
1
<?php
2
3
/*
4
 * This file is part of the Ivory Serializer package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ivory\Serializer\Mapping\Annotation;
13
14
/**
15
 * @Annotation
16
 * @Target({"PROPERTY", "METHOD"})
17
 *
18
 * @author GeLo <[email protected]>
19
 */
20
class XmlCollection
21
{
22
    /**
23
     * @var string|null
24
     */
25
    private $entry;
26
27
    /**
28
     * @var string|null
29
     */
30
    private $entryAttribute;
31
32
    /**
33
     * @var bool|null
34
     */
35
    private $keyAsAttribute;
36
37
    /**
38
     * @var bool|null
39
     */
40
    private $keyAsNode;
41
42
    /**
43
     * @var bool|null
44
     */
45
    private $inline;
46
47
    /**
48
     * @param mixed[] $data
49
     */
50 36
    public function __construct(array $data)
51
    {
52 36
        if (isset($data['entry'])) {
53 36
            $this->entry = $data['entry'];
54 18
        }
55
56 36
        if (isset($data['entry_attribute'])) {
57 36
            $this->entryAttribute = $data['entry_attribute'];
58 18
        }
59
60 36
        if (isset($data['key_as_attribute'])) {
61 36
            $this->keyAsAttribute = $data['key_as_attribute'];
62 18
        }
63
64 36
        if (isset($data['key_as_node'])) {
65 36
            $this->keyAsNode = $data['key_as_node'];
66 18
        }
67
68 36
        if (isset($data['inline'])) {
69 36
            $this->inline = $data['inline'];
70 18
        }
71 36
    }
72
73
    /**
74
     * @return bool
75
     */
76 36
    public function hasEntry()
77
    {
78 36
        return $this->entry !== null;
79
    }
80
81
    /**
82
     * @return string|null
83
     */
84 36
    public function getEntry()
85
    {
86 36
        return $this->entry;
87
    }
88
89
    /**
90
     * @return bool
91
     */
92 36
    public function hasEntryAttribute()
93
    {
94 36
        return $this->entryAttribute !== null;
95
    }
96
97
    /**
98
     * @return string|null
99
     */
100 36
    public function getEntryAttribute()
101
    {
102 36
        return $this->entryAttribute;
103
    }
104
105
    /**
106
     * @return bool
107
     */
108 36
    public function hasKeyAsAttribute()
109
    {
110 36
        return $this->keyAsAttribute !== null;
111
    }
112
113
    /**
114
     * @return bool|null
115
     */
116 36
    public function useKeyAsAttribute()
117
    {
118 36
        return $this->keyAsAttribute;
119
    }
120
121
    /**
122
     * @return bool
123
     */
124 36
    public function hasKeyAsNode()
125
    {
126 36
        return $this->keyAsNode !== null;
127
    }
128
129
    /**
130
     * @return bool|null
131
     */
132 36
    public function useKeyAsNode()
133
    {
134 36
        return $this->keyAsNode;
135
    }
136
137
    /**
138
     * @return bool
139
     */
140 36
    public function hasInline()
141
    {
142 36
        return $this->inline !== null;
143
    }
144
145
    /**
146
     * @return bool|null
147
     */
148 36
    public function isInline()
149
    {
150 36
        return $this->inline;
151
    }
152
}
153