1 | <?php declare(strict_types = 1); |
||
17 | class CollectionReference implements ReferenceInterface |
||
18 | { |
||
19 | /** @var array Value of reference */ |
||
20 | protected $collection = []; |
||
21 | |||
22 | /** |
||
23 | * CollectionReference constructor. |
||
24 | * |
||
25 | * @param array|CollectionReference $collection |
||
26 | * @throws \InvalidArgumentException |
||
27 | * @throws ReferenceNotImplementsException |
||
28 | */ |
||
29 | 18 | public function __construct($collection = null) |
|
35 | |||
36 | /** |
||
37 | * Merge collections |
||
38 | * |
||
39 | * @param $collection |
||
40 | * @throws \InvalidArgumentException |
||
41 | * @throws ReferenceNotImplementsException |
||
42 | */ |
||
43 | 9 | public function merge($collection) |
|
53 | |||
54 | /** |
||
55 | * Get collection |
||
56 | * |
||
57 | * @return CollectionItem[] |
||
58 | * @throws ReferenceNotImplementsException |
||
59 | */ |
||
60 | 16 | public function getCollection() |
|
64 | |||
65 | /** |
||
66 | * Add item to collection |
||
67 | * |
||
68 | * @param CollectionItem $collectionItem |
||
69 | * @return CollectionReference |
||
70 | */ |
||
71 | 16 | public function addItem(CollectionItem $collectionItem): CollectionReference |
|
77 | |||
78 | /** |
||
79 | * Convert array to collection reference |
||
80 | * |
||
81 | * @param array $array |
||
82 | * @return CollectionReference |
||
83 | * @throws ReferenceNotImplementsException |
||
84 | * @throws \InvalidArgumentException |
||
85 | */ |
||
86 | 12 | public static function convertArrayToCollection(array $array) |
|
102 | |||
103 | /** |
||
104 | * Convert value to reference instance |
||
105 | * |
||
106 | * @param $value |
||
107 | * @return ReferenceInterface |
||
108 | * @throws \InvalidArgumentException |
||
109 | * @throws ReferenceNotImplementsException |
||
110 | */ |
||
111 | 18 | public static function convertValueToReference($value) |
|
135 | } |
||
136 |