File tree 3 files changed +9
-4
lines changed
3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -492,13 +492,18 @@ public function setEmpty() : static
492
492
* Sets the object to values in the array. Invalid array values are ignored.
493
493
*
494
494
* @param array<string,mixed> $values
495
- *
495
+ * @param array<string> $allowedFields list of allowed field names, other fields names will be ignored. Empty array updates all valid fields.
496
496
* @param bool $loaded set to true if you want to simulated being loaded from the db.
497
497
*/
498
- public function setFrom (array $ values , bool $ loaded = false ) : static
498
+ public function setFrom (array $ values , array $ allowedFields = [], bool $ loaded = false ) : static
499
499
{
500
500
$ this ->loaded = $ loaded ;
501
501
502
+ if (\count ($ allowedFields ))
503
+ {
504
+ $ values = \array_intersect_key ($ values , \array_flip ($ allowedFields ));
505
+ }
506
+
502
507
foreach ($ values as $ field => $ value )
503
508
{
504
509
if (isset (static ::$ fields [$ field ]))
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function next() : void
48
48
}
49
49
else
50
50
{
51
- $ this ->current ->setFrom ($ data , true );
51
+ $ this ->current ->setFrom ($ data , loaded: true );
52
52
}
53
53
++$ this ->index ;
54
54
}
Original file line number Diff line number Diff line change 32
32
*
33
33
* | Validator Name | Description | Parameters |
34
34
* | -------------- | ----------- | ----------- |
35
- * | alnum | Numbers and characters only (ctype_alnum) | None |
35
+ * | alpha_numeric | Numbers and characters only (ctype_alnum) | None |
36
36
* | alpha | Characters only (ctype_alpha) | None |
37
37
* | bool | Must be one or zero | None |
38
38
* | card | Credit card number (LUHN validation) | None |
You can’t perform that action at this time.
0 commit comments