Skip to content

Commit

Permalink
Enum support for ArrayHelper::toArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
uaoleg authored Nov 6, 2023
1 parent aa9adc8 commit f4a97f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion framework/helpers/BaseArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ public static function toArray($object, $properties = [], $recursive = true)
if (is_array($object)) {
if ($recursive) {
foreach ($object as $key => $value) {
if (is_array($value) || is_object($value)) {
if ($value instanceof \UnitEnum) {
$object[$key] = $value->value;
} elseif (is_array($value) || is_object($value)) {
$object[$key] = static::toArray($value, $properties, true);
}
}
Expand Down

0 comments on commit f4a97f9

Please sign in to comment.