src/Mapper/Entry.php
private function formatValue(string $type, $value, string $itemsType = null)
    {
        // Certain fields are already built as objects (Location, Link, DateTimeImmutable)
        // if the entry has already been built partially.
        // We restore these objects to their JSON implementations to avoid conflicts.
        if (\is_object($value) && $value instanceof \JsonSerializable) {
            $value = guzzle_json_decode(guzzle_json_encode($value), true);
        }

        if (null === $value) {
            return null;
        }

        switch ($type) {
            case 'Array':
                return \array_map(function ($value) use ($itemsType) {
                    return $this->formatValue((string) $itemsType, $value);
                }, $value);
            case 'Date':
                return new DateTimeImmutable($value, new \DateTimeZone('UTC'));
            case 'Link':
                return new Link($value['sys']['id'], $value['sys']['linkType']);
            case 'Location':
                return new Location($value['lat'], $value['lon']);
            case 'RichText':
                return $this->richTextParser->parse($value);
            default:
                return $value;
        }
    }
private function formatValue(string $type, $value, string $itemsType = null)
    {
        // Certain fields are already built as objects (Location, Link, DateTimeImmutable)
        // if the entry has already been built partially.
        // We restore these objects to their JSON implementations to avoid conflicts.
        if (\is_object($value) && $value instanceof \JsonSerializable) {
            $value = guzzle_json_decode(guzzle_json_encode($value), true);
        }

        if (null === $value) {
            return null;
        }

        switch ($type) {
            case 'Array':
                return \array_map(function ($value) use ($itemsType) {
                    return $this->formatValue((string) $itemsType, $value);
                }, $value);
            case 'Date':
                return new DateTimeImmutable($value, new \DateTimeZone('UTC'));
            case 'Link':
                return new Link($value['sys']['id'], $value['sys']['linkType']);
            case 'Location':
                return new Location($value['lat'], $value['lon']);
            case 'RichText':
                return $this->richTextParser->parse($value);
            default:
                return $value;
        }
    }
private function formatValue ( string $ type , $ value , string $ itemsType = null ) { // Certain fields are already built as objects (Location, Link, DateTimeImmutable) // if the entry has already been built partially. // We restore these objects to their JSON implementations to avoid conflicts. if ( \ is_object ( $ value ) && $ value instanceof \ JsonSerializable ) { $ value = guzzle_json_decode ( guzzle_json_encode ( $ value ) , true ) ; } if ( null === $ value ) { return null ; } switch ( $ type ) { case 'Array' : return \ array_map ( function ( $ value ) use ( $ itemsType ) { return $ this -> formatValue ( ( string ) $ itemsType , $ value ) ; } , $ value ) ; case 'Date' : return new DateTimeImmutable ( $ value , new \ DateTimeZone ( 'UTC' ) ) ; case 'Link' : return new Link ( $ value [ 'sys' ] [ 'id' ] , $ value [ 'sys' ] [ 'linkType' ] ) ; case 'Location' : return new Location ( $ value [ 'lat' ] , $ value [ 'lon' ] ) ; case 'RichText' : return $ this -> richTextParser -> parse ( $ value ) ; default : return $ value ; } }
Transforms values from the original JSON representation to an appropriate PHP representation.

@param string      $type
@param mixed       $value
@param string|null $itemsType The type of the items in the array, if it's an array field

@return mixed
Transforms values from the original JSON representation to an appropriate PHP representation .