src/Utils/Reflection/ReflectionUtil.php
private static function transformValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($value instanceof PrimalValued) {
            $value = $value->toPrimitive();
        } elseif ($value instanceof Arrayable) {
            $value = $value->toArray();
            if (empty($value)) {
                $value = null;
            }
        } elseif (is_array($value)) {
            $value = array_map(function ($arrValue) {
                return self::transformValue($arrValue);
            }, $value);
        } elseif ($value instanceof \DateTimeZone) {
            $value = $value->getName();
        } elseif ($value instanceof Carbon) {
            $value = $value->toRfc3339String();
        }

        return $value;
    }
private static function transformValue($value)
    {
        if (is_null($value)) {
            return $value;
        }

        if ($value instanceof PrimalValued) {
            $value = $value->toPrimitive();
        } elseif ($value instanceof Arrayable) {
            $value = $value->toArray();
            if (empty($value)) {
                $value = null;
            }
        } elseif (is_array($value)) {
            $value = array_map(function ($arrValue) {
                return self::transformValue($arrValue);
            }, $value);
        } elseif ($value instanceof \DateTimeZone) {
            $value = $value->getName();
        } elseif ($value instanceof Carbon) {
            $value = $value->toRfc3339String();
        }

        return $value;
    }
private static function transformValue ( $ value ) { if ( is_null ( $ value ) ) { return $ value ; } if ( $ value instanceof PrimalValued ) { $ value = $ value -> toPrimitive ( ) ; } elseif ( $ value instanceof Arrayable ) { $ value = $ value -> toArray ( ) ; if ( empty ( $ value ) ) { $ value = null ; } } elseif ( is_array ( $ value ) ) { $ value = array_map ( function ( $ arrValue ) { return self :: transformValue ( $ arrValue ) ; } , $ value ) ; } elseif ( $ value instanceof \ DateTimeZone ) { $ value = $ value -> getName ( ) ; } elseif ( $ value instanceof Carbon ) { $ value = $ value -> toRfc3339String ( ) ; } return $ value ; }
Transform the value.

@param mixed $value

@return array|float|int|null|string
Transform the value .