1 | <?php |
||
9 | class AttributeBag extends Collection implements AttributeBagContract |
||
10 | { |
||
11 | /** |
||
12 | * Create new AttributeBag. |
||
13 | * |
||
14 | * @param array $attributes |
||
15 | */ |
||
16 | public function __construct($attributes = []) |
||
22 | |||
23 | /** |
||
24 | * Add or update attribute. |
||
25 | * |
||
26 | * @param \Sofa\Eloquence\Metable\Attribute|string $key |
||
27 | * @param mixed $value |
||
28 | * @return $this |
||
29 | */ |
||
30 | public function set($key, $value = null) |
||
44 | |||
45 | /** |
||
46 | * Set attribute. |
||
47 | * |
||
48 | * @param \Sofa\Eloquence\Metable\Attribute $attribute |
||
49 | */ |
||
50 | protected function setInstance(Attribute $attribute) |
||
60 | |||
61 | /** |
||
62 | * Set attribute. |
||
63 | * |
||
64 | * @param \Sofa\Eloquence\Metable\Attribute $attribute |
||
65 | */ |
||
66 | public function add($attribute) |
||
70 | |||
71 | /** |
||
72 | * Set attribute. |
||
73 | * |
||
74 | * @param \Sofa\Eloquence\Metable\Attribute $attribute |
||
75 | */ |
||
76 | protected function addInstance(Attribute $attribute) |
||
80 | |||
81 | /** |
||
82 | * Update existing attribute. |
||
83 | * |
||
84 | * @param \Sofa\Eloquence\Metable\Attribute|string $key |
||
85 | * @param mixed $value |
||
86 | * @return $this |
||
87 | */ |
||
88 | protected function update($key, $value = null) |
||
99 | |||
100 | /** |
||
101 | * New attribute instance. |
||
102 | * |
||
103 | * @param string $key |
||
104 | * @param mixed $value |
||
105 | * @return \Sofa\Eloquence\Metable\Attribute |
||
106 | */ |
||
107 | protected function newAttribute($key, $value) |
||
111 | |||
112 | /** |
||
113 | * Get attribute value. |
||
114 | * |
||
115 | * @param string $key |
||
116 | * @return mixed |
||
117 | */ |
||
118 | public function getValue($key) |
||
124 | |||
125 | /** |
||
126 | * Get collection as key-value array. |
||
127 | * |
||
128 | * @return array |
||
129 | */ |
||
130 | public function toArray() |
||
136 | |||
137 | /** |
||
138 | * Unset attribute. |
||
139 | * |
||
140 | * @param string $key |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function forget($key) |
||
151 | |||
152 | /** |
||
153 | * Set attribute. |
||
154 | * |
||
155 | * @param string $key |
||
156 | * @param mixed $value |
||
157 | * @return void |
||
158 | */ |
||
159 | public function offsetSet($key, $value) |
||
163 | |||
164 | /** |
||
165 | * Set attribute to null. |
||
166 | * |
||
167 | * @param string $key |
||
168 | * @return void |
||
169 | */ |
||
170 | public function offsetUnset($key) |
||
174 | |||
175 | /** |
||
176 | * Handle dynamic properties. |
||
177 | * |
||
178 | * @param string $key |
||
179 | * @param mixed $value |
||
180 | */ |
||
181 | public function __set($key, $value) |
||
185 | |||
186 | /** |
||
187 | * Handle dynamic properties. |
||
188 | * |
||
189 | * @param string $key |
||
190 | * @return mixed |
||
191 | */ |
||
192 | public function __get($key) |
||
196 | |||
197 | /** |
||
198 | * Handle isset calls. |
||
199 | * |
||
200 | * @param string $key |
||
201 | * @return boolean |
||
202 | */ |
||
203 | public function __isset($key) |
||
207 | |||
208 | /** |
||
209 | * Handle unset calls. |
||
210 | * |
||
211 | * @param string $key |
||
212 | * @return void |
||
213 | */ |
||
214 | public function __unset($key) |
||
218 | |||
219 | /** |
||
220 | * Create copy of the attribute bag. |
||
221 | * |
||
222 | * @return static |
||
223 | */ |
||
224 | public function replicate($except = null) |
||
236 | } |
||
237 |