Create a source image from the decoded  JSON data.

@param array $data Decoded JSON data

@return SourceImage
771705
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']
        );
    }
579554
public function populate($data = array())
    {
        if (isset($data['title']) && $data['title'] !== null) {
            $this->title = $data['title'];
        }

        if (isset($data['description']) && $data['description'] !== null) {
            $this->description = $data['description'];
        }

        if (isset($data['jsonData']) && $data['jsonData'] !== null) {
            $this->jsonData = $data['jsonData'];
        }

        if (isset($data['distribution']) && $data['distribution'] !== null) {
            $this->distribution = $data['distribution'];
        }

        if (isset($data['type']) && $data['type'] !== null) {
            $this->type = $data['type'];
        }

        if (isset($data['family']) && $data['family'] !== null) {
            $this->family = $data['family'];
        }

        $this->points = (!empty($data['points']))?
        $this->points = $data['points']:
        0;

        if (!empty($data['image'])) {
            $this->image = $data['image'];
        }

        $this->availability = (!empty($data['availability']))?
        \DateTime::createFromFormat('d/m/Y H:i:s', $data['availability']):
        null;
    }
180885
public static function createFromData(array $data)
    {
        if (!isset($data['type'])) {
            throw new DomainException(self::MSG_REQUIRED_TYPE);
        }

        if (!in_array($data['type'], self::allowedRejectionTypes(), true)) {
            throw new DomainException(self::MSG_UNSUPPORTED_TYPE);
        }

        return new self($data);
    }
353973
public function create(array $data) {
    $tweet = new Tweet();

    $media = new Media();
    $media->setUrl($data['user']['profile_image_url']);

    $author = new Author();
    $author->setProfilePicture($media);
    $author->setIdentifier($data['user']['id']);
    $author->setName($data['user']['name']);
    $author->setLink('https://twitter.com/' . $data['user']['screen_name']);
    $author->setUsername($data['user']['screen_name']);

    $tweet
        ->setFollowersCount($data['user']['followers_count'])
        ->setIdentifier($data['id'])
        ->setMessage($data['full_text'])
        ->setCreatedAt(new \DateTime($data['created_at']))
        ->setAuthor($author);

    if (isset($data['retweeted_status']['full_text'])) {
      $tweet->setMessage($data['retweeted_status']['full_text']);
    }

    $this->addTweetReferences($tweet, $data);
    $this->addTweetMedias($tweet, $data);

    return $tweet;
  }
320178
public function createCollection(array $data = [])
    {
        $collection = new Images();

        foreach ($data as $item) {
            $collection->add(null, $this->create($item));
        }

        return $collection;
    }
540089
protected function createLegacyXml(array $data)
    {
        $data['uri'] = $this->urlRedecorator->redecorateFromSource($data['uri']);
        $pathInfo = pathinfo($data['uri']);

        return $this->fillXml($data, $pathInfo, time());
    }
970350
public function image($data)
    {
        $value = isset($data['src']) ? $data['src'] : null;
        $url   = isset($data['url']) ? $data['url'] : null;
        if (!$value) {
            return null;
        }
        
        $params = $url ? ['url' => Ioc::url($url)] : null;
        return HtmlHelper::image($value, $params);
    }
1155655
protected function createReceiveImageMsg(array $data)
    {
        $result = new WxReceiveImageMsg();
        $this->initReceiveMsg($result, $data);
        $result->setMediaId(isset($data['MediaId']) ? trim($data['MediaId']) : '');
        $result->setPicUrl(isset($data['PicUrl']) ? trim($data['PicUrl']) : '');
        return $result;
    }
245339
public static function arr2json($data)
    {
        $json = json_encode(self::buildEnEmojiData($data), JSON_UNESCAPED_UNICODE);
        return $json === '[]' ? '{}' : $json;
    }
1065553
public static function loadSerializedJsonJWS(array $data)
    {
        $jws = new JWS();

        foreach ($data['signatures'] as $signature) {
            $bin_signature = Base64Url::decode($signature['signature']);
            $protected_headers = self::getProtectedHeaders($signature);
            $headers = self::getHeaders($signature);

            $jws = $jws->addSignatureFromLoadedData($bin_signature, $protected_headers, $headers);
        }

        self::populatePayload($jws, $data);

        return $jws;
    }
1103266
public static function createFromArray(array $data)
    {
        $self = new self();

        foreach ($data as $searchResult) {
            $self->addSearchResult(KeySearchResult::createFromArray($searchResult));
        }

        return $self;
    }
646519
public function create(array $data)
    {
        $response = $this->ontraport->post(
            $this->getNamespace(), $this->toArray($data)
        );

        return $this->ontraport->item($this, $response);
    }
840500
public function createMediaImage(array $data = [])
    {
        $type  = $this->resolveImageType(array_key_exists('image_type', $data) ? $data['image_type'] : null);
        $image = $this->hydrate($type, $data);

        if (array_key_exists('media', $data) && array_key_exists('media_type', $data)) {
            switch ($data['media_type']) {
                case "movie":
                    $factory = new MovieFactory($this->getHttpClient());
                    break;

                case "tv":
                    $factory = new TvFactory($this->getHttpClient());
                    break;
                    
                case "season":
                    $factory = new TvSeasonFactory($this->getHttpClient());
                    break;
                    
                // I don't think this ever occurs, but just in case..
                case "episode":
                    $factory = new TvEpisodeFactory($this->getHttpClient());
                    break;

                // I don't think this ever occurs, but just in case..
                case "person":
                    $factory = new PeopleFactory($this->getHttpClient());
                    break;

                default:
                    throw new RuntimeException(sprintf(
                        'Unrecognized media_type "%s" for method "%s::%s".',
                        $data['media_type'],
                        __CLASS__,
                        __METHOD__
                    ));
            }

            $media = $factory->create($data['media']);

            $image->setMedia($media);
        }

        return $image;
    }
223694
public static function deserialize(array $data)
    {
        return new static(
            new UUID($data['media_object_id']),
            new MIMEType($data['mime_type']),
            new StringLiteral($data['description']),
            new StringLiteral($data['copyright_holder']),
            Url::fromNative($data['source_location']),
            array_key_exists('language', $data) ? new Language($data['language']) : new Language('nl')
        );
    }
499533
private function generateImageLine(array $data): string
    {
        $images = '';

        if (\count($data['images']) > 1000) {
            $data['images'] = array_splice($data['images'], 1000);
        }

        $builder = [
            'url' => 'loc',
            'location' => 'geo_location',
        ];

        foreach ($data['images'] as $image) {
            $images .= '<image:image>';

            foreach ($image as $key => $element) {
                $images .= sprintf('<image:%1$s>%2$s</image:%1$s>', ($builder[$key] ?? $key), $element);
            }

            $images .= '</image:image>';
        }

        return sprintf('    '.'<url><loc>%s</loc>%s</url>'."\n", $data['url'], $images);
    }
1284151
public function create(array $data)
    {
        $scene = '';
        if (func_num_args() === 2) {
            $scene = func_get_arg(1);
        }

        $this->setOriginal($data);

        $this->setData($this->guardResult($data, $scene));

        if ($this->fireEvent('creating', $data) === false) {
            return false;
        }

        $model = $this->driver->create($this->getData());

        $this->fireEvent('created', $model);

        return $model;
    }
1198982
public static function loadSerializedJsonJWE(array $data)
    {
        $jwe = new JWE();
        $jwe = $jwe->withCiphertext(Base64Url::decode($data['ciphertext']));

        self::populateIV($jwe, $data);
        self::populateAAD($jwe, $data);
        self::populateTag($jwe, $data);
        self::populateSharedProtectedHeaders($jwe, $data);
        self::populateSharedHeaders($jwe, $data);

        foreach ($data['recipients'] as $recipient) {
            $encrypted_key = self::getRecipientEncryptedKey($recipient);
            $recipient_headers = self::getRecipientHeaders($recipient);

            $jwe = $jwe->addRecipientWithEncryptedKey($encrypted_key, $recipient_headers);
        }

        return $jwe;
    }