src/Core/SourceImage.php
public static function createFromDecodedJsonResponse($data)
    {
        if (!isset($data['user_metadata'])) {
            $data['user_metadata'] = [];
        } else {
            foreach ($data['user_metadata'] as $key => $value) {
                if (0 === strpos($key, 'date:')) {
                    $data['user_metadata'][$key] = new \DateTime($value);
                }
            }
        }
        if (!isset($data['static_metadata'])) {
            $data['static_metadata'] = [];
        }

        $dynamic_metadata = [];

        // Rebuild the DynamicMetadata associated to the current SourceImage
        if (isset($data['dynamic_metadata'])) {
            foreach ($data['dynamic_metadata'] as $name => $metadata) {
                $metadata = DynamicMetadataHelper::buildDynamicMetadata($name, $metadata);
                if ($metadata) {
                    $dynamic_metadata[$name] = $metadata;
                }
            }
        }

        return new self(
            $data['organization'],
            $data['binary_hash'],
            $data['hash'],
            $data['name'],
            $data['format'],
            $data['size'],
            $data['width'],
            $data['height'],
            $data['user_metadata'],
            $dynamic_metadata,
            $data['static_metadata'],
            new \DateTime($data['created']),
            $data['link'],
            $data['short_hash']
        );
    }
public static function createFromDecodedJsonResponse($data)
    {
        if (!isset($data['user_metadata'])) {
            $data['user_metadata'] = [];
        } else {
            foreach ($data['user_metadata'] as $key => $value) {
                if (0 === strpos($key, 'date:')) {
                    $data['user_metadata'][$key] = new \DateTime($value);
                }
            }
        }
        if (!isset($data['static_metadata'])) {
            $data['static_metadata'] = [];
        }

        $dynamic_metadata = [];

        // Rebuild the DynamicMetadata associated to the current SourceImage
        if (isset($data['dynamic_metadata'])) {
            foreach ($data['dynamic_metadata'] as $name => $metadata) {
                $metadata = DynamicMetadataHelper::buildDynamicMetadata($name, $metadata);
                if ($metadata) {
                    $dynamic_metadata[$name] = $metadata;
                }
            }
        }

        return new self(
            $data['organization'],
            $data['binary_hash'],
            $data['hash'],
            $data['name'],
            $data['format'],
            $data['size'],
            $data['width'],
            $data['height'],
            $data['user_metadata'],
            $dynamic_metadata,
            $data['static_metadata'],
            new \DateTime($data['created']),
            $data['link'],
            $data['short_hash']
        );
    }
public static function createFromDecodedJsonResponse ( $ data ) { if ( ! isset ( $ data [ 'user_metadata' ] ) ) { $ data [ 'user_metadata' ] = [ ] ; } else { foreach ( $ data [ 'user_metadata' ] as $ key => $ value ) { if ( 0 === strpos ( $ key , 'date:' ) ) { $ data [ 'user_metadata' ] [ $ key ] = new \ DateTime ( $ value ) ; } } } if ( ! isset ( $ data [ 'static_metadata' ] ) ) { $ data [ 'static_metadata' ] = [ ] ; } $ dynamic_metadata = [ ] ; // Rebuild the DynamicMetadata associated to the current SourceImage if ( isset ( $ data [ 'dynamic_metadata' ] ) ) { foreach ( $ data [ 'dynamic_metadata' ] as $ name => $ metadata ) { $ metadata = DynamicMetadataHelper :: buildDynamicMetadata ( $ name , $ metadata ) ; if ( $ metadata ) { $ dynamic_metadata [ $ name ] = $ metadata ; } } } return new self ( $ data [ 'organization' ] , $ data [ 'binary_hash' ] , $ data [ 'hash' ] , $ data [ 'name' ] , $ data [ 'format' ] , $ data [ 'size' ] , $ data [ 'width' ] , $ data [ 'height' ] , $ data [ 'user_metadata' ] , $ dynamic_metadata , $ data [ 'static_metadata' ] , new \ DateTime ( $ data [ 'created' ] ) , $ data [ 'link' ] , $ data [ 'short_hash' ] ) ; }
Create a source image from the decoded  JSON data.

@param array $data Decoded JSON data

@return SourceImage
Create a source image from the decoded JSON data .