src/Encoder/ObjectEncoder.php
private function encodeObjectArray($object, array $options, callable $encode)
    {
        if (!\in_array((string) $options['object.format'], ['array', 'vars', 'iterate'], true)) {
            throw new \RuntimeException('Invalid object encoding format: ' . $options['object.format']);
        }

        $output = $encode($this->getObjectArray($object, $options['object.format']));

        if ($options['object.cast']) {
            $output = '(object)' . ($options['whitespace'] ? ' ' : '') . $output;
        }

        return $output;
    }
private function encodeObjectArray($object, array $options, callable $encode)
    {
        if (!\in_array((string) $options['object.format'], ['array', 'vars', 'iterate'], true)) {
            throw new \RuntimeException('Invalid object encoding format: ' . $options['object.format']);
        }

        $output = $encode($this->getObjectArray($object, $options['object.format']));

        if ($options['object.cast']) {
            $output = '(object)' . ($options['whitespace'] ? ' ' : '') . $output;
        }

        return $output;
    }
private function encodeObjectArray ( $ object , array $ options , callable $ encode ) { if ( ! \ in_array ( ( string ) $ options [ 'object.format' ] , [ 'array' , 'vars' , 'iterate' ] , true ) ) { throw new \ RuntimeException ( 'Invalid object encoding format: ' . $ options [ 'object.format' ] ) ; } $ output = $ encode ( $ this -> getObjectArray ( $ object , $ options [ 'object.format' ] ) ) ; if ( $ options [ 'object.cast' ] ) { $ output = '(object)' . ( $ options [ 'whitespace' ] ? ' ' : '' ) . $ output ; } return $ output ; }
Encodes the object into one of the array formats.
@param object $object Object to encode as PHP
@param array $options List of encoder options
@param callable $encode Callback used to encode values
@return string The object encoded as string
@throws \RuntimeException If the object format is invalid
Encodes the object into one of the array formats .