@@ -178,14 +178,7 @@ public function __toString(): string
178178 return $ this ->name ;
179179 }
180180
181- public function addValue (string $ tag ,string $ value ): void
182- {
183- $ this ->_values ->put (
184- $ tag ,
185- $ this ->_values
186- ->get ($ tag ,collect ())
187- ->push ($ value ));
188- }
181+ /* INTERFACE */
189182
190183 public function current (): mixed
191184 {
@@ -237,6 +230,24 @@ public function offsetUnset(mixed $offset): void
237230 // We cannot clear values using array syntax
238231 }
239232
233+ /* METHODS */
234+
235+ public function addValue (string $ tag ,array $ values ): void
236+ {
237+ $ this ->_values ->put (
238+ $ tag ,
239+ array_unique (array_merge ($ this ->_values
240+ ->get ($ tag ,[]),$ values )));
241+ }
242+
243+ public function addValueOld (string $ tag ,array $ values ): void
244+ {
245+ $ this ->_values_old ->put (
246+ $ tag ,
247+ array_unique (array_merge ($ this ->_values_old
248+ ->get ($ tag ,[]),$ values )));
249+ }
250+
240251 /**
241252 * Return the hints about this attribute, ie: RDN, Required, etc
242253 *
@@ -266,8 +277,10 @@ public function hints(): array
266277 */
267278 public function isDirty (): bool
268279 {
269- return ($ this ->values_old ->count () !== $ this ->values ->count ())
270- || ($ this ->values ->diff ($ this ->values_old )->count () !== 0 );
280+ return (($ a =$ this ->values_old ->dot ())->keys ()->count () !== ($ b =$ this ->values ->dot ())->keys ()->count ())
281+ || ($ a ->values ()->count () !== $ b ->values ()->count ())
282+ || ($ a ->keys ()->diff ($ b ->keys ())->count () !== 0 )
283+ || ($ a ->values ()->diff ($ b ->values ())->count () !== 0 );
271284 }
272285
273286 /**
@@ -329,4 +342,18 @@ public function required(): Collection
329342 ? $ this ->oc ->intersect ($ this ->required_by ->keys ())->sort ()
330343 : collect ();
331344 }
345+
346+ public function tagValues (string $ tag ='' ): Collection
347+ {
348+ return $ this ->_values
349+ ->filter (fn ($ item ,$ key )=>($ key === $ tag ))
350+ ->values ();
351+ }
352+
353+ public function tagValuesOld (string $ tag ='' ): Collection
354+ {
355+ return $ this ->_values_old
356+ ->filter (fn ($ item ,$ key )=>($ key === $ tag ))
357+ ->values ();
358+ }
332359}
0 commit comments