Parse the response document

@access protected
@throws AuthenticationErrorException,
InvalidArgumentException,
RuntimeException
@return array
497596
protected function doParse()
    {
        $object = $this->objectNameToKey($this->objectName);

        if ('ok' !== $this->data['@attributes']['stat']) {
            $errorCode = (int) $this->data['@attributes']['err_code'];
            $errorMessage = $this->data['err'];

            if (in_array($errorCode, array(1, 15))) {
                throw new AuthenticationErrorException($errorMessage, $errorCode);
            } else {
                throw new RuntimeException($errorMessage, $errorCode);
            }
        } else {
            if (array_key_exists('result', $this->data)) {
                $this->parseMultiRecordResult($object, $this->data);
            } elseif (array_key_exists($object, $this->data)) {
                $this->parseSingleRecordResult($object, $this->data);
            } elseif (array_key_exists('api_key', $this->data)) {
                $this->resultCount = 0;
                $this->result = $this->data['api_key'];
            } else {
                $asString = true;
                throw new RuntimeException('Unknown response format: '.$this->responseObj->getBoby($asString));
            }
        }
    }
964521
public function parse() {
		$annotations = [];
		preg_match_all(self::ANNOTATION_PATTERN, $this->rawDocComment, $found);
		foreach ($found[1] as $key => $value) {
			$arg = null;
			if (!empty($found[2][$key])) {
				$arg = substr(trim($found[2][$key]), 1, -1);
			}
			$annotations[] = new Annotation($value, $this->parseValue($found[3][$key]), $arg);
		}
		return $annotations;
	}
1090920
public function parse() : array
    {
        $buffer = $this->routing_rule;
        
        $section_list_set = [];
        $current_list = [];
        do
        {
            $pos = strpos(substr($buffer,1),'/');
            $section = $pos !== false ? substr($buffer, 1, $pos) : substr($buffer, 1);
            $buffer = $pos !== false ? substr($buffer, $pos + 1) : '';
            
            $length = strlen($section);
            if ($length === 0){
                $current_list[] = new class implements EmptyRoutingPathInterface {};
                if (!empty($buffer)){
                    throw new RoutingRuleParseException($this->routing_rule, "Empty routing section is allowed only for last element");
                }
                break;
            }
            $first = $section[0];
            $last = $section[$length - 1];
            if ($first === '[' && $last === ']'){
                // push current list
                $section_list_set[] = $current_list + ['()'];
                // add optional part to current list
                $inside = substr($section, 1, $length - 2);
                if ($inside[0] === ':') {
                    $current_list[] = self::parseVariablePattern($inside);
                }
                else {
                    $current_list[] = $inside;
                }
            }
            else if ($first === ':') {
                $current_list[] = self::parseVariablePattern($section);
            }
            else {
                $current_list[] = $section;
            }
        }
        while(!empty($buffer));
        
        $section_list_set[] = $current_list;
        return $section_list_set;
    }
200398
public function getArray()
    {
        $contents = file_get_contents($this->context);

        $parsed = json_decode($contents, true);

        if (is_null($parsed)) {
            throw new InvalidFileException('Unable to parse invalid JSON file at ' . $this->context);
        }

        return $parsed;
    }
1289670
private function parseArgs(): array
    {
        if (null === $this->options && count($this->longopts) === 0 && null === $this->userInput) {
            return $this->fixArgs($_SERVER['argv']);
        }

        if (null !== $this->userInput) {
            $this->collectOptionsFromUserInputClass();
        }

        $parseCommandLineOptions = $this->cliOptionParser;
        $parsedVars = $parseCommandLineOptions($this->options, $this->longopts);
        if (false === $parsedVars) {
            throw new \RuntimeException(
                    'Error parsing "' . join(' ', $_SERVER['argv'])
                    . '" with ' . $this->options
                    . ' and ' . join(' ', $this->longopts)
            );
        }

        return $this->fixArgs($_SERVER['argv'], $parsedVars);
    }
471713
public function parse($request)
    {
        $object = clone $this->requestObject;
        $invalidValues = [];

        foreach ($this->propertyParsers as $propertyParser) {
            try {
                $this->setProperty($request, $object, $propertyParser);
            } catch (InvalidValueException $e) {
                $invalidValues[$propertyParser->getName()] = $e->getMessage();
            }
        }
        $this->checkIfRequestIsValidOrThrowException($invalidValues);

        return $object;
    }
746010
function _parse()
    {
        $this->serviceList = array();

        $services = $this->parser->evalXPath('xrd:Service', $this->xrdNode);

        foreach ($services as $node) {
            $s = new Auth_Yadis_Service();
            $s->element = $node;
            $s->parser = $this->parser;

            $priority = $s->getPriority();

            if ($priority === null) {
                $priority = SERVICES_YADIS_MAX_PRIORITY;
            }

            $this->_addService($priority, $s);
        }
    }
1351311
public function toArray()
    {
        if ($this->getResponseType() == 'application/json')
        {
            $response = $this->convertJsonToArray($this->getBody());
        }
        elseif ($this->getResponseType() == 'application/binary')
        {
            $response = $this->convertSerializedToArray($this->getBody());
        }
        else
        {
            $response = null;
        }

        if ( ! is_array($response))
        {
            $this->throwResponseConversionException();
        }

        return $response;
    }
1080705
public function validated(): array
    {
        $config = $this->container->make('katsana.manager')->config('webhook');

        $signature = new Signature($config['signature']);
        $header = $this->header('X_SIGNATURE') ?? '';

        if (! $signature->verify($header, $this->getContent(), ($config['threshold'] ?? 3600))) {
            throw new HttpException(419, 'Unable to verify X-Signature.');
        }

        return $this->post();
    }
838587
public function parse()
    {
        if (!is_array($this->paramList)) {
            return [];
        }

        $parsedParams = [];
        foreach ($this->paramList as $p) {
            $param = new ParsedParameter();
            $param->name = $p->name;
            $param->type = $this->getType($p->name, $this->paramAnnotations);
            $param->matchPattern = $this->getParamMatchType($param->type);
            try {
                $param->default = $p->getDefaultValue();
                if (is_bool($param->default)) {
                    $param->default = ($param->default===false) ? '0' : '1';
                }
                $param->required = false;
            } catch (\Exception $e) {
                $param->default = null;
                $param->required = true;
            }

            $parsedParams[] = $param;
        }

        return $parsedParams;
    }
974929
public function getResponse()
    {
        $this->response = new ResponseDocument();
        $this->response->addElement("responseDate", $this->toUtcDateTime(new \DateTime()));
        $requestNode = $this->response->createElement("request", $this->repository->getBaseUrl());
        $this->response->getDocument()->documentElement->appendChild($requestNode);

        try {
            $this->checkVerb();
            $verbOutput = $this->doVerb();

            // we are sure now that all request variables are correct otherwise an error would have been thrown
            foreach ($this->params as $k => $v) {
                $requestNode->setAttribute($k, $v);
            }

            // the element is only added when everything went fine, otherwise we would add error node(s) in the catch
            // block below
            $this->response->getDocument()->documentElement->appendChild($verbOutput);

            // Shift the records from the records stack and add them to the DOM tree
            // Records proper are always stored in the 'metadata' node
            foreach ($this->response->getDocument()->getElementsByTagName('metadata') as $item) {
                $record = array_shift($this->records);
                $node = $this->response->getDocument()->importNode($record->documentElement, true);
                $item->appendChild($node);
            }
        } catch (MultipleExceptions $errors) {
            //multiple errors happened add all of the to the response
            foreach ($errors as $error) {
                $this->response->addError($error);
            }
        } catch (\Exception $error) {
            //add this error to the response
            if ($error instanceof Exception) {
                $this->response->addError($error);
            } else {
                $this->response->addError(new Exception($error->getMessage()));
            }
        }

        return $this->response->getResponse();
    }
190620
public function parse()
    {
        if ($this->body === false) {
            return null;
        }

        $result = [];
        $key = null;
        foreach ($this->body as $value) {
            if (!is_null($key)) {
                $result[$key] = $value;
                $key = null;
            } else {
                $key = $value;
            }
        }

        return $result;
    }
113702
protected function parse()
    {
        $json = $this->httpResponse->json();

        $service = new Service();

        (new ArrayUtils())->callSetters(
            $service,
            $json,
            [
                'autodestroy', 'autorestart', 'bindings', 'container_envvars',
                'container_ports', 'containers', 'cpu_shares',
                'current_num_containers', 'deployed_datetime',
                'deployment_strategy', 'destroyed_datetime', 'entrypoint',
                'image_name', 'image_tag', 'link_variables',
                'linked_from_service', 'memory', 'name', 'privileged',
                'public_dns', 'resource_uri', 'roles', 'run_command',
                'running_num_containers', 'sequential_deployment',
                'started_datetime', 'state', 'stopped_datetime',
                'stopped_num_containers', 'tags', 'target_num_containers',
                'unique_name', 'uuid', 'webhook'
            ]
        );

        $this->service = $service;
    }
1042331
private function parse() {
        $data = json_decode($this->httpResponse->getBody(), true);

        foreach ($data['messages'] as $message) {
            $msg = new Message($message);
            $this->messages[] = $msg;

            if ($message['type'] === 'error' || $message['type'] === 'non-document-error') {
                $this->errors[] = $msg;
            } else if ($message['type'] === 'warning') {
                $this->warnings[] = $msg;
            }
        }
    }
578426
public function getData()
    {
        $this->validate(
            'username',
            'password',
            'transactionId',
            'currency'
        );

        $document = new \DOMDocument('1.0', 'utf-8');
        $document->formatOutput = false;
        $document->createElement('soapenv:Header');

        $envelope = $document->appendChild(
            $document->createElementNS('http://schemas.xmlsoap.org/soap/envelope/', 'soapenv:Envelope')
        );
        $envelope->setAttribute('xmlns:urn', 'urn:pscservice');

        $body = $envelope->appendChild(
            $document->createElement('soapenv:Body')
        );

        $serialNumbers = $body->appendChild(
            $document->createElement('urn:getSerialNumbers')
        );

        $serialNumbers->appendChild(
            $document->createElement('urn:username', $this->getUsername())
        );

        $serialNumbers->appendChild(
            $document->createElement('urn:password', $this->getPassword())
        );

        $serialNumbers->appendChild(
            $document->createElement('urn:mtid', $this->getTransactionId())
        );

        $serialNumbers->appendChild(
            $document->createElement('urn:subId', $this->getSubId())
        );

        $serialNumbers->appendChild(
            $document->createElement('urn:currency', $this->getCurrency())
        );

        return $document->saveXML();
    }
159481
public static function Parse(){
            $oThis = self::CreateInstanceIfNotExists();
            $sRoot = str_replace(array("index.php", " "), array("", "%20"), $_SERVER["SCRIPT_NAME"]);//Bugfix
            $sUri = ($sRoot != "/") ? str_replace($sRoot, "", $_SERVER["REQUEST_URI"]) : substr($_SERVER["REQUEST_URI"], 1, strlen($_SERVER["REQUEST_URI"])-1);
            $aParsedRoute = explode("/", $sUri);
            $mID = (array_key_exists(1, $aParsedRoute)) ? $aParsedRoute[1] : null;
            $sMethod = $oThis->Restful();  
            $oThis->RestParams();

            if(!$oThis->bOverloadFrontend){
                $bResult = Bootstrap::AutoLoad(((!empty($aParsedRoute[0]) && $aParsedRoute[0] != "/" ) ? strtolower(str_replace("@", "", $aParsedRoute[0])) : "main"));

                if(!$bResult)
                    Bootstrap::AutoLoad("main");
            }
            
            $sUri = preg_replace("/\?.*$/", "", $sUri);//Removendo path
            $sUri = preg_replace("/\#.*$/", "", $sUri);//Removendo path
            $bCall = false;

            $aIdent = array("int" => "\d+", "str" => "\w+", "flt" => "[\d.]+");

            foreach($oThis->aRoutes as $sRoute => $fFunc){  
                if (preg_match_all('/{(?P<field>\w+)(:((?P<type>\w{3,3})|regex\((?P<regex>.*)\)))?(:(?P<notnull>notnull))?}/i',$sRoute, $aMatches)){
                    if (preg_match('/(?P<pre>.*\w)\/\{/i',$sRoute, $aMatch)){
                        $sOk = str_replace('/', '\/', $aMatch['pre']);
                        $sRoute = str_replace($aMatch['pre'], $sOk, $sRoute);
                    } 
                    foreach ($aMatches['field'] as $iKey => $sValue) {
                        if ($aMatches['regex'][$iKey]){
                            if ($aMatches['notnull'][$iKey] == 'notnull'){
                                $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':regex('.$aMatches['regex'][$iKey].'):notnull}/i',"\/(".$aMatches['regex'][$iKey].")", $sRoute);
                            }else{
                                $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':regex('.$aMatches['regex'][$iKey].')}/i',"\/?(".$aMatches['regex'][$iKey].")?", $sRoute);                                                                                
                            }
                        }else{
                            if ($aMatches['type'][$iKey]){ 
                                if ($aMatches['notnull'][$iKey] == 'notnull'){
                                    $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':'.$aMatches['type'][$iKey].':notnull}/i',"\/(".$aIdent[$aMatches['type'][$iKey]].")", $sRoute);                                        
                                }else{
                                    $sRoute = preg_replace('/\/?{'.$aMatches['field'][$iKey].':'.$aMatches['type'][$iKey].'}/i',"\/?(".$aIdent[$aMatches['type'][$iKey]].")?", $sRoute);                                        
                                }
                            }else{
                                if ($aMatches['notnull'][$iKey] == 'notnull'){
                                    $sRoute = preg_replace('/\/{'.$aMatches['field'][$iKey].':notnull}/i',"\/([^\/]*)", $sRoute);                                        
                                }else{
                                    $sRoute = preg_replace("/\/?{".$aMatches['field'][$iKey]."}/", "\/?([^\/]*)?", $sRoute);                                                                                            
                                }
                            }
                        } 
                    }
                }
                else{
                    $sRoute = str_replace('/', '\/', $sRoute);
                }                    
                
                if(preg_match_all("/^".$sRoute."\/?$/i", $sMethod."_".$sUri, $aMatches)){
                    $aParams = array();
                    foreach($aMatches as $iKey => $aResult){
                        if($iKey > 0){
                            $aParams[] = $aResult[0];
                        }
                    }

                    $bCall = true; 
                    Storage::Set("route.request", $sRoute);

                    if(is_array($fFunc)){
                        if(is_array($fFunc[1]))
                            $aParams = array_merge($fFunc[1], $aParams);
                        else
                            $aParams = array_merge(array($fFunc[1]), $aParams);

                        call_user_func_array($fFunc[0], $aParams);
                    }
                    else{
                        call_user_func_array($fFunc, $aParams);
                    }

                    break;
                }              
            }        
            
            if(array_key_exists("__dynamicroute", $oThis->aRoutes) && !$bCall)
                call_user_func($oThis->aRoutes["__dynamicroute"]);  
            else
                Output::SendHTTPCode(404);
        }
127958
public function parse($credential = array())
    {
        if (array_key_exists(self::PUBKEY_FILE, $credential)) {
            $type = self::PUBKEY_FILE;
            $data = $credential[self::PUBKEY_FILE];
        } elseif (array_key_exists(self::PASSWORD, $credential)) {
            $type = self::PASSWORD;
            $data = $credential[self::PASSWORD];
        } else {
            $type = self::NONE;
            $data = isset($credential[self::NONE]) ? $credential[self::NONE] : array();
        }

        return array($type, $data);
    }