Create a SubjectArea from the decoded JSON data.

@param array $data Decoded JSON data

@return SubjectArea
553950
public static function createFromDecodedJsonResponse($data)
    {
        // Make sure to build the SubjectArea with correct defaults in case of missing attributes.
        $data = array_merge(['x' => 0, 'y' => 0, 'width' => 1, 'height' => 1], $data);

        return new self(
            max(0, $data['x']),
            max(0, $data['y']),
            max(1, $data['width']),
            max(1, $data['height'])
        );
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
1025124
public static function fromData(array $data)
    {
        $group = new static(array_map(function ($data) {
            return $data['class']::fromData($data['params']);
        }, $data['constraints']));

        return $group->logicalOperator($data['logicalOperator']);
    }
112084
public function create(array $data): PodiumResponse
    {
        /* @var $rankForm ModelFormInterface */
        $rankForm = $this->getForm();

        if (!$rankForm->loadData($data)) {
            return PodiumResponse::error();
        }

        return $rankForm->create();
    }
266919
public static function fromArray($data)
    {
        $email = new SimpleEmail();
        $email->setSubject($data["subject"]);

        foreach($data["recipients"] as $recipient){
            $email->addRecipientByEmail($recipient["email"], $recipient["name"]);
        }

        foreach($data["attachments"] as $attachment){
            $email->addAttachment($attachment["path"], $attachment["name"]);
        }

        $email->setReplyToRecipient($data['ReplyTo']['email'], $data['ReplyTo']['name']);

        $email->setText($data["text"]);
        $email->setHtml($data["html"]);
        $email->setSender($data["sender"]["email"], $data["sender"]["name"]);

        return $email;
    }
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;
    }
1247915
public static function createFromArray(array $data)
    {
        $self = new self();

        if (isset($data['id'])) {
            $self->setId($data['id']);
        }
        if (isset($data['name'])) {
            $self->setName($data['name']);
        }
        if (isset($data['code'])) {
            $self->setCode($data['code']);
        }

        return $self;
    }
713211
protected function create(array $data)
    {
        $user = UserGate::create([
            'first_name' => $data[ 'first_name' ],
            'last_name'  => $data[ 'last_name' ],
            'username'   => $data[ 'username' ],
            'email'      => $data[ 'email' ],
            'password'   => bcrypt($data[ 'password' ]),
            'enabled'    => 1,
        ]);

        if ($user) {
            $user->attachRole(2);
        }

        return $user;
    }
1060326
public function create($data)
    {
        $request = $this->getRequest();
        $response = $this->getResponse();
        $storyTellingService = $this->getStorytellingService();
        $domainService = $this->getDomainService();
        $user = null;
        
        $data = $this->fromJson();
        $storyMappingId = $data['story_mapping_id'];
        $storyMapping = $domainService->getStoryMappingMapper()->findById($storyMappingId);
        
        if (! $storyMapping) {
            $content = array(
                'result' => array(
                    'message' => 'Story missing',
                    'success' => false,
                    'data' => null,
                ),
            );
            
            $response->setContent($adapter->serialize($content));
            return $response;
        }

        $domain = $this->getDomainService()->getDomain($this);

        $storyTelling = new \PlaygroundFlow\Entity\OpenGraphStoryTelling();
        
        $storyTelling->setObject(json_encode($data['objects']))
            ->setPoints($storyMapping->getPoints())
            ->setSecretKey(null);

        if (!empty($data['user']['email'])) {
            // J'ai un user qui est identifié : user playground
            $user = $this->getUserService()->findUserOrCreateByEmail($data['user']['email']);
        
            // Association prospect - user si c'etait un prospect avant
            $prospect = $this->getProspectService()->getProspectMapper()->findOneBy(array('prospect' => $data['user']['anonymous']));
            if (!empty($prospect)) {
                if ($prospect->getUser() == null) {
                    $prospect->setUser($user);
                    $prospect = $this->getProspectService()->getProspectMapper()->update($prospect);
                }
                $storyTelling->setProspect($prospect);
            }
            $userDomain = $this->getUserDomainService()->findUserDomainOrCreateByUserAndDomain($user, $domain);
            // Association story telling à un utilisateur
            $storyTelling->setUser($user);
        } elseif (!empty($data['user']['anonymous'])) {
            // J'ai un anonymous
            $prospect = $this->getProspectService()->findProspectOrCreateByProspectAndDomain($data['user']['anonymous'], $domain);
            // Association story telling à un prospect
            $storyTelling->setProspect($prospect);
        }
        
        $storyTelling->setOpenGraphStoryMapping($storyMapping);
        // Creation de la storyTelling
        $storyTellingService->getStoryTellingMapper()->insert($storyTelling);

        // Si il y a un user, on met a jour son classement
        if (!empty($user)) {
            $this->getLeaderboardService()->addPoints($storyMapping, $user);
        }

        $storyTellingService->tellStory($storyTelling);
        
        $this->getEventManager()->trigger('story.'.$storyMapping->getId(), $this, array('storyTelling' => $storyTelling));
        
        $contentType = 'application/json';
        $adapter = '\Zend\Serializer\Adapter\Json';
        $response->getHeaders()->addHeaderLine('Content-Type', $contentType);
        $adapter = new $adapter;
        
        $data = $this->fromJson();
        $content = array(
            'result' => array(
                'message' => 'Post detected',
                'success' => true,
                'data' => $data['objects'],
            ),
        );
        
        $response->setContent($adapter->serialize($content));
        
        return $response;
    }
420957
public static function decodeData($data)
    {
        if (\is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = \urldecode($value);
            }

            return $data;
        }

        return \urldecode($data);
    }
1009679
public static function buildEnEmojiData(array $data)
    {
        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $data[$key] = self::buildEnEmojiData($value);
            } elseif (is_string($value)) {
                $data[$key] = self::emojiEncode($value);
            } else {
                $data[$key] = $value;
            }
        }
        return $data;
    }
364108
public static function CreateFromResponse(array $data)
    {
        if (array_key_exists("data", $data) && is_array($data["data"]))
        {
            $data = $data["data"];
        }

        $object_field = new self($data["alias"], $data["type"], $data["options"], $data["required"], $data["unique"]);
        if ($data["field"])
        {
            $object_field->setField($data["field"]);
        }
        if ($data["id"])
        {
            $object_field->setId($data["id"]);
        }
        return $object_field;
    }
42722
protected function createPagination(array $data = null)
    {
        $pagination = new Pagination();
        if ($data !== null) {
            $pagination->setData($data);
        }
        return $pagination;
    }
1296036
protected function create(array $data)
    {
        return User::create([
            'name' => $data['name'],
            'email' => $data['email'],
            'password' => bcrypt($data['password']),
            'token' => $this->userRepository->createToken(),
            'active' => 1,
        ]);
    }
1362239
public function appendJson($data)
    {
        $jsonData = json_decode($data, true);

        if (is_null($jsonData)) {
            $this->_errorsList['json_decode'] = 'Json cannot be decoded.';
            $this->_hasErrors = true;
            return $this;
        }

        $this->appendArray($jsonData);

        if ($this->_objectCreation) {
            return $this->_afterAppendDataToNewObject();
        }
        return $this;
    }
869588
protected function create(array $data)
  {
    //Ceate User
    $user = User::create([
      'name' => $data['name'],
      'email' => $data['email'],
      'password' => bcrypt($data['password']),
    ]);

    //create Blank profile
    $profile = Profile::create([
      'user_id' => $user->id,
      'bio'     => '',
    ]);
    $profile->save();

    //Assign User Role
    $user->assign('user');
    return $user;
  }
560285
public static function fromData(array $data)
    {
        $policies = [];
        foreach (isset($data['schedule']) ? $data['schedule'] : [] as $policyData) {
            $policies[] = new Policy($policyData['interval'], $policyData['count']);
        }

        return new static($policies, isset($data['manual_count']) ? $data['manual_count'] : 1);
    }