Conditions | 6 |
Paths | 8 |
Total Lines | 19 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function add($object) |
||
19 | { |
||
20 | if (is_string($object)) { |
||
21 | $object = [ $object ]; |
||
22 | } |
||
23 | if (!is_object($object) && !is_array($object)) { |
||
24 | throw new HttpResponseException('You can add only object'); |
||
25 | } |
||
26 | |||
27 | if ($this->serializationRule !== ResponseBag::SINGLE_OBJECT) { |
||
28 | $this->collection[] = $object; |
||
29 | return; |
||
30 | } |
||
31 | |||
32 | if (is_object($object)) { |
||
33 | $object = [$object]; |
||
34 | } |
||
35 | $this->collection = array_merge($this->collection, $object); |
||
36 | } |
||
37 | |||
62 |