Creates a new Deployment from parsed response body.

@param array $parsed The parsed response body in array representation

@return Deployment
489320
public static function create($parsed)
    {
        $result = new self();
        $name = Utilities::tryGetValue($parsed, Resources::XTAG_NAME);
        $label = Utilities::tryGetValue($parsed, Resources::XTAG_LABEL);
        $url = Utilities::tryGetValue($parsed, Resources::XTAG_URL);
        $locked = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_LOCKED
        );
        $rollbackAllowed = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_ROLLBACK_ALLOWED
        );
        $sdkVersion = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_SDK_VERSION
        );
        $inputEndpointList = Utilities::tryGetKeysChainValue(
            $parsed,
            Resources::XTAG_INPUT_ENDPOINT_LIST,
            Resources::XTAG_INPUT_ENDPOINT
        );
        $roleList = Utilities::tryGetKeysChainValue(
            $parsed,
            Resources::XTAG_ROLE_LIST,
            Resources::XTAG_ROLE
        );
        $roleInstanceList = Utilities::tryGetKeysChainValue(
            $parsed,
            Resources::XTAG_ROLE_INSTANCE_LIST,
            Resources::XTAG_ROLE_INSTANCE
        );
        $status = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_STATUS
        );
        $slot = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_DEPLOYMENT_SLOT
        );
        $privateId = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_PRIVATE_ID
        );
        $configuration = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_CONFIGURATION
        );
        $upgradeDomainCount = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_UPGRADE_DOMAIN_COUNT
        );
        $upgradeStatus = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_UPGRADE_STATUS
        );

        $result->setConfiguration($configuration);
        $result->setLabel($label);
        $result->setLocked(Utilities::toBoolean($locked));
        $result->setName($name);
        $result->setPrivateId($privateId);
        $result->setRollbackAllowed(Utilities::toBoolean($rollbackAllowed));
        $result->setSdkVersion($sdkVersion);
        $result->setSlot($slot);
        $result->setStatus($status);
        $result->setUpgradeDomainCount(intval($upgradeDomainCount));
        $result->setUpgradeStatus(UpgradeStatus::create($upgradeStatus));
        $result->setUrl($url);
        $result->setRoleInstanceList(
            Utilities::createInstanceList(
                Utilities::getArray($roleInstanceList),
                'WindowsAzure\ServiceManagement\Models\RoleInstance'
            )
        );
        $result->setRoleList(
            Utilities::createInstanceList(
                Utilities::getArray($roleList),
                'WindowsAzure\ServiceManagement\Models\Role'
            )
        );
        $result->setInputEndpointList(
            Utilities::createInstanceList(
                Utilities::getArray($inputEndpointList),
                'WindowsAzure\ServiceManagement\Models\InputEndpoint'
            )
        );

        return $result;
    }
649845
public function setParsed(bool $parsed = true): Result
    {
        $this->parsed = (boolean) $parsed;
        return $this;
    }
1123904
public function create(array $attributes)
    {
        if (!is_null($this->validator)) {
            // we should pass data that has been casts by the model
            // to make sure data type are same because validator may need to use
            // this data to compare with data that fetch from database.
            if( $this->versionCompare($this->app->version(), "5.2.*", ">") ){
                $attributes = $this->model->newInstance()->forceFill($attributes)->makeVisible($this->model->getHidden())->toArray();
            }else{
                $model = $this->model->newInstance()->forceFill($attributes);
                $model->addVisible($this->model->getHidden());
                $attributes = $model->toArray();
            }

            $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_CREATE);
        }

        $model = $this->model->newInstance($attributes);
        $model->save();
        $this->resetModel();

        event(new RepositoryEntityCreated($this, $model));

        return $this->parserResult($model);
    }
563927
public function create($buildSid) {
        $data = Values::of(array('BuildSid' => $buildSid, ));

        $payload = $this->version->create(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new DeploymentInstance(
            $this->version,
            $payload,
            $this->solution['serviceSid'],
            $this->solution['environmentSid']
        );
    }
471132
public function withPost(array $params)
    {
        $request = $this;
        if ($this->isJson()) {
            $body = json_encode($params);
        } else {
            $body = http_build_query($params);
            if (!$this->hasHeader('Content-Type')) {
                $request = $this->withHeader('Content-Type', 'application/x-www-form-urlencoded');
            }
        }

        return new self(
            $request->getMethod(),
            $request->getUri(),
            $request->getHeaders(),
            $body,
            $request->getProtocolVersion(),
            $request->getRetries(),
            $request->getOptions(),
            $this->getServiceKey(),
            $this->getRequestKey()
        );
    }
968894
protected function addProtocolPortIfNeeded(string $matched, array $parsed) : string
    {
        if ('' === $matched || '*' === $matched) {
            $return = $matched;

            return $return;
        }
        $protocol = 'https://';
        $port     = 0;
        if (true === isset($parsed['scheme'])) {
            $this->addLog('Parsed a protocol from origin: '.$parsed['scheme']);
            $protocol = $parsed['scheme'].'://';
        } else {
            $this->addLog('Unable to parse protocol/scheme from origin');
        }
        if (true === isset($parsed['port'])) {
            $this->addLog('Parsed a port from origin: '.$parsed['port']);
            $port = (int) $parsed['port'];
        } else {
            $this->addLog('Unable to parse port from origin');
        }

        if (0 === $port) {
            if ('https://' === $protocol) {
                $port = 443;
            } else {
                $port = 80;
            }
        }

        if (('http://' === $protocol && 80 === $port) || ('https://' === $protocol && 443 === $port)) {
            $return = $protocol.$matched;
        } else {
            $return = $protocol.$matched.':'.$port;
        }
        return $return;
    }
250669
public function create(array $parameters)
    {
        $supported = $this->isSupported('create');

        return (true === $supported) ? $this->makeRequest($this->endpoint.'/new', $parameters, 'POST') : $supported;
    }
1317274
public static function create($parsed)
    {
        $result = new self();
        $keys = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_STORAGE_SERVICE_KEYS
        );
        $result->_url = Utilities::tryGetValue($parsed, Resources::XTAG_URL);
        $result->_primary = Utilities::tryGetValue(
            $keys,
            Resources::XTAG_PRIMARY
        );
        $result->_secondary = Utilities::tryGetValue(
            $keys,
            Resources::XTAG_SECONDARY
        );

        return $result;
    }
559779
protected static function decompile(array $parsed) : self
    {
        $problem = new static();


        if (!empty($parsed['title'])) {
            $problem->setTitle($parsed['title']);
        }
        if (!empty($parsed['type'])) {
            $problem->setType($parsed['type']);
        }
        if (!empty($parsed['status'])) {
            $problem->setStatus((int) $parsed['status']);
        }
        if (!empty($parsed['detail'])) {
            $problem->setDetail($parsed['detail']);
        }
        if (!empty($parsed['instance'])) {
            $problem->setInstance($parsed['instance']);
        }

        // Remove the defined keys. That means whatever is left must be a custom
        // extension property.
        unset($parsed['title'], $parsed['type'], $parsed['status'], $parsed['detail'], $parsed['instance']);

        foreach ($parsed as $key => $value) {
            $problem[$key] = $value;
        }

        return $problem;
    }
437842
public static function create($parsed)
    {
        $result = new self();
        $properties = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_HOSTED_SERVICE_PROPERTIES
        );
        $result->_hostedService = new HostedService($parsed, $properties);

        return $result;
    }
1324659
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];
        $message = Message::create($payload['message']);

        return new static($senderId, $recipientId, $timestamp, $message);
    }
241542
public function newInstance($cloned = array())
    {
        if ($cloned instanceof Model) {
            $cloned = $cloned->toArray(Model::FETCH_PUBLISHED);
        }

        if (isset($this->options['model'])) {
            $Model = $this->options['model'];
            return new $Model($cloned, array('collection' => $this));
        } else {
            return new Model($cloned, array('collection' => $this));
        }
    }
108190
public static function create(array $payload): self
    {
        $senderId = $payload['sender']['id'];
        $recipientId = $payload['recipient']['id'];
        $timestamp = $payload['timestamp'];
        $optin = Optin::create($payload['optin']);

        return new static($senderId, $recipientId, $timestamp, $optin);
    }
450660
protected function apply(array $parsed, Config $config)
    {
        if (isset($parsed['commands']) && is_array($parsed['commands'])) {
            $currentCommands = $config->get('commands', []);
            if (!is_array($currentCommands)) {
                $currentCommands = [];
            }
            $currentCommands += $parsed['commands'];
            $config->set('commands', $currentCommands);
        }

        if (isset($parsed['hooks']) && is_array($parsed['hooks'])) {
            $currentHooks = $config->get('hooks', []);
            if (!is_array($currentHooks)) {
                $currentHooks = [];
            }
            foreach ($parsed['hooks'] as $type => $hooks) {
                if (!is_array($hooks)) {
                    if (strlen($hooks)) {
                        $hooks = [$hooks];
                    } else {
                        $hooks = [];
                    }
                }
                if (!isset($currentHooks[$type])) {
                    $currentHooks[$type] = $hooks;
                } else {
                    foreach ($hooks as $hook) {
                        $currentHooks[$type][] = $hook;
                    }
                }
            }
            $config->set('hooks', $currentHooks);
        }

        if (isset($parsed['config'])) {
            $config->set($parsed['config']);
        }

        if (isset($parsed['uses']) && is_array($parsed['uses']) && count($parsed['uses'])) {
            foreach ($parsed['uses'] as $use => $useSettings) {
                $config->setDefaultItem('uses', $use, $useSettings);
            }
        }
    }
7493
protected function parsedCodeHasNamespaces(array $parsed)
    {
        // Namespaces can only be on first level in the code,
        // so we make only check on it.
        $node = array_filter(
            $parsed,
            function ($value) {
                return $value instanceof NamespaceNode;
            }
        );

        return !empty($node);
    }
603064
public static function fromSuccess(array $params)
    {
        $matchResult = new self();
        $matchResult->type = 'success';
        $matchResult->params = $params;
        return $matchResult;
    }
1219188
public function create($installedAddOnSid) {
        $data = Values::of(array('InstalledAddOnSid' => $installedAddOnSid, ));

        $payload = $this->version->create(
            'POST',
            $this->uri,
            array(),
            $data
        );

        return new AssignedAddOnInstance(
            $this->version,
            $payload,
            $this->solution['accountSid'],
            $this->solution['resourceSid']
        );
    }