Completed
Push — standalone ( ee9bba...36bfab )
by Philip
02:39
created

ClassMetadata::setService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Dontdrinkandroot\RestBundle\Metadata;
4
5
use Dontdrinkandroot\RestBundle\Metadata\Annotation\Right;
6
use Metadata\MergeableClassMetadata;
7
use Metadata\MergeableInterface;
8
9
class ClassMetadata extends MergeableClassMetadata
10
{
11
    /**
12
     * @var bool
13
     */
14
    public $restResource;
15
16
    /**
17
     * @var string
18
     */
19
    public $namePrefix;
20
21
    /**
22
     * @var string
23
     */
24
    public $pathPrefix;
25
26
    /**
27
     * @var string
28
     */
29
    public $service;
30
31
    /**
32
     * @var string
33
     */
34
    public $controller;
35
36
    /**
37
     * @var Right|null
38
     */
39
    public $postRight;
40
41
    /**
42
     * @var Right|null
43
     */
44
    public $putRight;
45
46
    /**
47
     * @var Right|null
48
     */
49
    public $deleteRight;
50
51
    /**
52
     * @var Right|null
53
     */
54
    public $listRight;
55
56
    /**
57
     * @var Right|null
58
     */
59
    public $getRight;
60
61
    /**
62
     * @var string[]
63
     */
64
    public $methods = ['LIST', 'POST', 'GET', 'PUT', 'DELETE'];
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 6
    public function merge(MergeableInterface $object)
70
    {
71 6
        parent::merge($object);
72
73
        /** @var ClassMetadata $object */
74 6
        $this->restResource = $object->restResource;
75 6
        $this->namePrefix = $object->namePrefix;
76 6
        $this->pathPrefix = $object->pathPrefix;
77 6
        $this->service = $object->service;
78 6
        $this->controller = $object->controller;
79 6
        $this->listRight = $object->listRight;
80 6
        $this->getRight = $object->getRight;
81 6
        $this->postRight = $object->postRight;
82 6
        $this->putRight = $object->putRight;
83 6
        $this->deleteRight = $object->deleteRight;
84 6
        $this->methodMetadata = array_merge($this->methodMetadata, $object->methodMetadata);
85 6
        $this->propertyMetadata = array_merge($this->propertyMetadata, $object->propertyMetadata);
86 6
    }
87
88
    /**
89
     * @param bool $restResource
90
     */
91 34
    public function setRestResource($restResource)
92
    {
93 34
        $this->restResource = $restResource;
94 34
    }
95
96
    /**
97
     * @return boolean
98
     */
99 4
    public function isRestResource()
100
    {
101 4
        return $this->restResource;
102
    }
103
104
    /**
105
     * @return string
106
     */
107 4
    public function getNamePrefix()
108
    {
109 4
        return $this->namePrefix;
110
    }
111
112
    /**
113
     * @param string $namePrefix
114
     */
115
    public function setNamePrefix($namePrefix)
116
    {
117
        $this->namePrefix = $namePrefix;
118
    }
119
120
    /**
121
     * @return string
122
     */
123 4
    public function getPathPrefix()
124
    {
125 4
        return $this->pathPrefix;
126
    }
127
128
    /**
129
     * @param string $pathPrefix
130
     */
131 20
    public function setPathPrefix(string $pathPrefix)
132
    {
133 20
        $this->pathPrefix = $pathPrefix;
134 20
    }
135
136
    /**
137
     * @return string
138
     */
139 4
    public function getController()
140
    {
141 4
        return $this->controller;
142
    }
143
144
    /**
145
     * @param string $controller
146
     */
147
    public function setController($controller)
148
    {
149
        $this->controller = $controller;
150
    }
151
152
    /**
153
     * @return string
154
     */
155 4
    public function getService()
156
    {
157 4
        return $this->service;
158
    }
159
160
    /**
161
     * @param string $service
162
     */
163 4
    public function setService($service)
164
    {
165 4
        $this->service = $service;
166 4
    }
167
168
    /**
169
     * @return Right|null
170
     */
171 2
    public function getDeleteRight()
172
    {
173 2
        return $this->deleteRight;
174
    }
175
176
    /**
177
     * @param Right|null $deleteRight
178
     */
179
    public function setDeleteRight(Right $deleteRight)
180
    {
181
        $this->deleteRight = $deleteRight;
182
    }
183
184
    /**
185
     * @return Right|null
186
     */
187 2
    public function getPostRight()
188
    {
189 2
        return $this->postRight;
190
    }
191
192
    /**
193
     * @param Right|null $postRight
194
     */
195
    public function setPostRight(Right $postRight)
196
    {
197
        $this->postRight = $postRight;
198
    }
199
200
    /**
201
     * @return Right|null
202
     */
203 6
    public function getPutRight()
204
    {
205 6
        return $this->putRight;
206
    }
207
208
    /**
209
     * @param Right|null $putRight
210
     */
211 20
    public function setPutRight(Right $putRight)
212
    {
213 20
        $this->putRight = $putRight;
214 20
    }
215
216
    /**
217
     * @return Right|null
218
     */
219 8
    public function getListRight()
220
    {
221 8
        return $this->listRight;
222
    }
223
224
    /**
225
     * @param Right|null $listRight
226
     */
227 20
    public function setListRight(Right $listRight)
228
    {
229 20
        $this->listRight = $listRight;
230 20
    }
231
232
    /**
233
     * @return Right|null
234
     */
235 10
    public function getGetRight()
236
    {
237 10
        return $this->getRight;
238
    }
239
240
    /**
241
     * @param Right|null $getRight
242
     */
243 20
    public function setGetRight(Right $getRight)
244
    {
245 20
        $this->getRight = $getRight;
246 20
    }
247
248
    /**
249
     * @return string[]
250
     */
251 4
    public function getMethods()
252
    {
253 4
        return $this->methods;
254
    }
255
256
    /**
257
     * @param string[] $methods
258
     */
259
    public function setMethods(array $methods)
260
    {
261
        $this->methods = $methods;
262
    }
263
264 34
    public function getPropertyMetadata(string $property): ?PropertyMetadata
265
    {
266 34
        if (array_key_exists($property, $this->propertyMetadata)) {
267 34
            return $this->propertyMetadata[$property];
268
        }
269
270 20
        return null;
271
    }
272
}
273