1 | <?php |
||
18 | trait CollectionTrait |
||
19 | { |
||
20 | use BaseTrait; |
||
21 | |||
22 | /** |
||
23 | * Returns property of item by name. |
||
24 | * |
||
25 | * @param mixed $name |
||
26 | * |
||
27 | * @return mixed |
||
28 | */ |
||
29 | public function get($name) |
||
33 | |||
34 | /** |
||
35 | * Sets an item. Silently resets if already exists. |
||
36 | * |
||
37 | * @param int|string $name |
||
38 | * @param mixed $value the element value |
||
39 | * @param string|array $where where to put, see [[setItem()]] |
||
40 | * |
||
41 | * @see setItem() |
||
42 | */ |
||
43 | 3 | public function set($name, $value, $where = '') |
|
47 | |||
48 | /** |
||
49 | * Adds an item. Does not touch if already exists. |
||
50 | * |
||
51 | * @param int|string $name item name. |
||
52 | * @param array $value item value. |
||
53 | * @param string|array $where where to put, see [[setItem()]] |
||
54 | * |
||
55 | * @return $this for chaining |
||
56 | * |
||
57 | * @see setItem() |
||
58 | */ |
||
59 | 3 | public function add($name, $value = null, $where = '') |
|
67 | /** |
||
68 | * Check collection has the item. |
||
69 | * |
||
70 | * @param string $name item name. |
||
71 | * |
||
72 | * @return bool whether item exist. |
||
73 | */ |
||
74 | public function has($name) |
||
78 | |||
79 | /** |
||
80 | * Delete an item. |
||
81 | * You can't create function `unset`. |
||
82 | * |
||
83 | * @param $name |
||
84 | */ |
||
85 | 1 | public function delete($name) |
|
89 | |||
90 | /** |
||
91 | * This method is overridden to support accessing items like properties. |
||
92 | * |
||
93 | * @param string $name item or property name |
||
94 | * |
||
95 | * @return mixed item of found or the named property value |
||
96 | */ |
||
97 | public function __get($name) |
||
101 | |||
102 | /** |
||
103 | * This method is overridden to support accessing items like properties. |
||
104 | * |
||
105 | * @param string $name item or property name |
||
106 | * @param string $value value to be set |
||
107 | * |
||
108 | * @return mixed item of found or the named property value |
||
109 | */ |
||
110 | 1 | public function __set($name, $value) |
|
114 | |||
115 | /** |
||
116 | * Checks if a property value is null. |
||
117 | * This method overrides the parent implementation by checking if the named item is loaded. |
||
118 | * |
||
119 | * @param string $name the property name or the event name |
||
120 | * |
||
121 | * @return bool whether the property value is null |
||
122 | */ |
||
123 | public function __isset($name) |
||
127 | |||
128 | /** |
||
129 | * Checks if a property value is null. |
||
130 | * This method overrides the parent implementation by checking if the named item is loaded. |
||
131 | * |
||
132 | * @param string $name the property name or the event name |
||
133 | * |
||
134 | * @return bool whether the property value is null |
||
135 | */ |
||
136 | public function __unset($name) |
||
140 | } |
||
141 |