Decompiles an array into an ApiProblem object.

@param array $parsed
An array parsed from JSON or XML to turn into an ApiProblem object.
@return ApiProblem
A new ApiProblem object.
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;
    }
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);
    }
1113980
public static function fromArray(array $params)
    {
        $options = new Options();

        if (isset($params['verbose'])) {
            $options->verbose = (bool) $params['verbose'];
        }

        if (isset($params['generate-imported'])) {
            $options->generateImported = (bool) $params['generate-imported'];
        }

        if (isset($params['psr4'])) {
            $options->psr4 = $params['psr4'];
        }

        return $options;
    }
1147987
public static function fromArray(array $attributes) {
		unset($attributes['id']);
		
		$attributesObject = new self();
		
		foreach ($attributes as $key => $value) {
			$attributesObject->add($key, $value);
		}
		
		return $attributesObject;
	}
1228736
public static function create($parsed)
    {
        $role = new self();
        $roleName = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_ROLE_NAME
        );
        $osVersion = Utilities::tryGetValue(
            $parsed,
            Resources::XTAG_OS_VERSION
        );

        $role->setOsVersion($osVersion);
        $role->setRoleName($roleName);

        return $role;
    }
1341581
public static function parse($answer)
    {
        if ( ! is_array($answer)) {
            return;
        }

        foreach ($answer as $key => $value) {
            $parsed = is_array($value) ? self::parse($value) : self::process($value);

            if ( ! empty($parsed)) {
                $answer[$key] = $parsed;
            } else {
                unset($answer[$key]);
            }
        }

        return $answer;
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
913378
protected function convertToObject($arrayElements)
	{
		$objects = array();
		
		foreach ($arrayElements as $key => $value) {
			$object = new \stdClass();
			$object->name = $key;
			$object->value = $value;
			$objects[] = $object;
		}

		return $objects;
	}
884369
public static function deserializeObject(array $data)
    {
        $subAttributes = [];
        if (isset($data['subAttributes'])) {
            foreach ($data['subAttributes'] as $subAttribute) {
                $subAttributes[] = static::deserializeObject($subAttribute);
            }
        }
        $result = new static(
            $data['name'],
            $data['type'],
            $data['multiValued'],
            $data['required'],
            isset($data['description']) ? $data['description'] : null,
            $subAttributes,
            isset($data['canonicalValues']) ? $data['canonicalValues'] : [],
            isset($data['caseExact']) ? $data['caseExact'] : false,
            $data['mutability'],
            $data['returned'],
            isset($data['uniqueness']) ? $data['uniqueness'] : null,
            isset($data['referenceTypes']) ? $data['referenceTypes'] : []
        );

        return $result;
    }
235716
public function decodeList(&$apiData)
    {
        $resObj = json_decode($apiData);
        if (isset($resObj->error)) {
            $msg = "Error " . $resObj->error->code . " " . $resObj->error->message;
            if (isset($resObj->error->errors[0])) {
                $msg .= " : " . $resObj->error->errors[0]->reason;
            }

            throw new \Exception($msg);
        } else {
            $this->page_info = [
                'resultsPerPage' => $resObj->pageInfo->resultsPerPage,
                'totalResults' => $resObj->pageInfo->totalResults,
                'kind' => $resObj->kind,
                'etag' => $resObj->etag,
                'prevPageToken' => null,
                'nextPageToken' => null,
            ];

            if (isset($resObj->prevPageToken)) {
                $this->page_info['prevPageToken'] = $resObj->prevPageToken;
            }

            if (isset($resObj->nextPageToken)) {
                $this->page_info['nextPageToken'] = $resObj->nextPageToken;
            }

            $itemsArray = $resObj->items;
            if (!is_array($itemsArray) || count($itemsArray) == 0) {
                return false;
            } else {
                return $itemsArray;
            }
        }
    }
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;
    }
190211
public function createRequestFromArray(array $headers): GenericRequest
    {
        $upperCaseHeaders = [];

        foreach ($headers as $header => $value) {
            $upperCaseHeader = mb_strtoupper(str_replace('-', '_', $header));

            if (0 !== mb_strpos($upperCaseHeader, 'HTTP_')) {
                $upperCaseHeader = 'HTTP_' . $upperCaseHeader;
            }

            if (!HeaderSecurity::isValid($value)) {
                $value = $this->filterHeader($value);
            }

            $upperCaseHeaders[$upperCaseHeader] = $value;
        }

        $message = ServerRequestFactory::fromGlobals($upperCaseHeaders);

        return $this->createRequestFromPsr7Message($message);
    }
76932
public static function create($parsed)
    {
        $result = new self();

        $result->setDeployment(Deployment::create($parsed));

        return $result;
    }
652635
public function fromArray(array $params)
    {
        foreach($params as $key => $value){
            $method = 'set' . ucfirst($key);
            if(method_exists($this, $method)){
                $this->$method($value);
            }
        }
        $this->normalize();
        return $this;
    }
923256
public static function createFromArray(array $params)
    {
        return new static(
            isset($params['method']) ? $params['method'] : 'GET',
            new Uri(isset($params['uri']) ? $params['uri'] : ''),
            isset($params['headers']) ? $params['headers'] : array(),
            isset($params['body']) ? (is_resource($params['body']) ? new Stream($params['body']) : Stream::createFromContents($params['body'])) : Stream::createFromContents(''),
            isset($params['server']) ? $params['server'] : array(),
            isset($params['cookies']) ? $params['cookies'] : array()
        );
    }
1341573
public static function fromSerialized($data)
    {
        if (!$data || !is_string($data)) {
            return null;
        }

        $decoded = json_decode($data, true);

        if (!is_array($decoded)) {
            return null;
        }

        return new self($decoded);
    }
661965
protected function parseRelationParameters(array $unparsed): array
    {
        $parseRelationParameters = [];
        $modelNamespace = \Phalcon\Di::getDefault()->getConfig()->namespace->models;

        foreach ($unparsed as $model => $query) {
            $modelName = str_replace(' ', '', ucwords(str_replace('_', ' ', $model)));
            $modelName = $modelNamespace . '\\' . $modelName;

            if (!class_exists($modelName)) {
                throw new \Exception('Related model does not exist.');
            }

            $parseRelationParameters[$modelName] = $this->parseSearchParameters($query)['mapped'];
        }

        return $parseRelationParameters;
    }