Build the validation return

@param array $body

@return array
557423
protected function buildValidationReturn(array $body)
    {
        if (isset($body['user'])) {
            $body['user'] = new User($body['user']);
        }

        $body['application'] = new Application($body['application']);
        $body['expire_at'] = new \DateTime($body['expire_at']);

        return $body;
    }
790050
private function separateParameters(array $body, array $parameters)
    {
        $keys = [];
        foreach ($parameters as $i => $j) {
            foreach ($body as $k => $v) {
                if ($v == sprintf('${%s}',strtoupper($i))){
                    unset($parameters[$i]);
                    continue;
                }
            }
            $keys[] = strtoupper(sprintf('${%s}', $i));
        }
        return array($parameters, $keys);
    }
198329
public function validateResponse(array $response)
    {
        $returnValue = false;
        if (isset($response['header'])
            && isset($response['header']['status'])
            && $response['header']['status'] >= 200
            && $response['header']['status'] < 300
        ) {
            $returnValue = true;
        }

        return $returnValue;
    }
870315
protected function getResponse(array $headers, $body)
	{
		// Create the response object.
		$return = new Response;

		// Set the body for the response.
		$return->body = $body;

		// Get the response code from the first offset of the response headers.
		preg_match('/[0-9]{3}/', array_shift($headers), $matches);
		$code = $matches[0];

		if (is_numeric($code))
		{
			$return->code = (int) $code;
		}

		// No valid response code was detected.
		else
		{
			throw new \UnexpectedValueException('No HTTP response code found.');
		}

		// Add the response headers to the response object.
		foreach ($headers as $header)
		{
			$pos = strpos($header, ':');
			$return->headers[trim(substr($header, 0, $pos))] = trim(substr($header, ($pos + 1)));
		}

		return $return;
	}
271029
private function validateJsonResponse($responseBody)
    {
        $data = json_decode($responseBody);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \Exception('Error decoding JSON.');
        }

        if (isset($data->error)) {
            throw new \Exception($data->error->error_message);
        }

        if (empty($data)) {
            throw new \Exception('No results found.');
        }

        return $responseBody;
    }
578606
private function parse($body)
    {
        $body = $this->substringBetween($body, '<CreditTransactionResult>', '</CreditTransactionResult>');

        $body = html_entity_decode($body);
        $xml = new \SimpleXMLElement($body);

        $resonse = array();

        $cmd= $xml->xpath('//CmdResponse');
        foreach ($cmd[0] as $name => $value) {
            $response[$name] = (string) $value;
        }

        if ($tran = $xml->xpath('//TranResponse')) {
            foreach ($tran[0] as $name => $value) {
                if ($name == 'Amount') {
                    foreach ($value as $key => $amount) {
                        $response[$key] = (string) $amount;
                    }
                } else {
                    $response[$name] = (string) $value;
                }
            }
        }

        return new Options($response);

    }
836203
private function parse_body(&$body)
    {
        // Mail_mimeDecode need \r\n end-line, but gpg may return \n
        $body = preg_replace('/\r?\n/', "\r\n", $body);

        // parse the body into structure
        $struct = rcube_mime::parse_message($body);

        return $struct;
    }
1150042
private function parse($body)
    {
        $response = array();

        $data = simplexml_load_string($body);

        foreach ($data as $node) {
            $this->parseElement($response, $node);
        }

        return new Options($response);
    }
1052777
private function getHeaders(array $userHeaders, $body): array
    {
        $headers = [
            'X-Contentful-User-Agent' => $this->userAgentGenerator->getUserAgent(),
            'Accept' => $this->apiContentType,
            'Accept-Encoding' => 'gzip',
            'Authorization' => 'Bearer '.$this->accessToken,
        ];

        if ($body) {
            $headers['Content-Type'] = $this->apiContentType;
        }

        return \array_merge($headers, $userHeaders);
    }
716416
public function getValidator(array $input)
    {
        if (!array_key_exists($this->column, $input)) {
            return false;
        }

        $input = array_only($input, $this->column);

        $form = $this->buildNestedForm($this->column, $this->builder);

        $rules = $attributes = [];

        /* @var Field $field */
        foreach ($form->fields() as $field) {
            if (!$fieldRules = $field->getRules()) {
                continue;
            }

            $column = $field->column();

            if (is_array($column)) {
                foreach ($column as $key => $name) {
                    $rules[$name.$key] = $fieldRules;
                }

                $this->resetInputKey($input, $column);
            } else {
                $rules[$column] = $fieldRules;
            }

            $attributes = array_merge(
                $attributes,
                $this->formatValidationAttribute($input, $field->label(), $column)
            );
        }

        array_forget($rules, NestedForm::REMOVE_FLAG_NAME);

        if (empty($rules)) {
            return false;
        }

        $newRules = [];

        foreach ($rules as $column => $rule) {
            foreach (array_keys($input[$this->column]) as $key) {
                $newRules["{$this->column}.$key.$column"] = $rule;
            }
        }

        return Validator::make($input, $newRules, $this->validationMessages, $attributes);
    }
470632
public function validate(array $toValidate = [])
    {
        $return = true;
        $validators = $this->getValidatorsForFields($toValidate);
        foreach ($validators as $validator) {
            $res = $validator->validate($toValidate);
            if ($res === false && $return === true) {
                $return = false;
            }
        }
        $elements = $this->getElements();
        foreach ($elements as $el) {
            if (
                (!empty($toValidate) && !in_array($el->getName(), $toValidate))
                || !($el instanceof \marvin255\serviform\interfaces\HasValidators)
            ) {
                continue;
            }
            $res = $el->validate();
            if ($res === false && $return === true) {
                $return = false;
            }
        }

        return $return;
    }
21840
protected function decodeBodyForFields(array $body, $bodyKey, array $fields)
    {
        if (!isset($body[$bodyKey])) {
            return $body;
        }
        $data = $body[$bodyKey];
        if (!isset($data[0])) {
            $data = array($data);
        }
        foreach ($data as $key => $value) {
            foreach ($fields as $field) {
                if (isset($value[$field])) {
                    $data[$key][$field] = base64_decode($value[$field]);
                }
            }
        }

        if (isset($body[$bodyKey][0])) {
            $body[$bodyKey] = $data;
        } else {
            $body[$bodyKey] = $data[0];
        }

        return $body;
    }
1041002
protected function unwrapEnvelope(array $body)
  {
    if (isset($body['data']))
    {
      return $body['data'];
    }
    else if (isset($body['items']))
    {
      $items = array();
      foreach ($body['items'] as $item)
      {
        $items[] = $item;
      }

      return $items;
    }
    return $body;
  }
1240805
protected function stringifyBooleans($body)
    {
        return array_map(function($value) {
            if (is_bool($value)) {
                return $value ? 'true' : 'false';
            } else if (is_array($value)) {
                return $this->stringifyBooleans($value);
            }
            return $value;
        }, $body);
    }
1128672
protected function verifyErrorFormat($body, $httpStatusCode)
    {
        if (is_array($body) === false)
        {
            $this->throwServerError($body, $httpStatusCode);
        }

        if ((isset($body['error']) === false) or
            (isset($body['error']['code']) === false))
        {
            $this->throwServerError($body, $httpStatusCode);
        }

        $code = $body['error']['code'];

        if (Errors\ErrorCode::exists($code) === false)
        {
            $this->throwServerError($body, $httpStatusCode);
        }
    }
796964
public function validate(array $input = []): ValidationResult
    {
        $results = [];

        foreach ($this->rules as $key => $definition) {

            $rules = $this->parser->parseRulesDefinition($definition);

            $results[$key] = $rules->validate($key, $input);

        }

        return new ValidationResult($results, $this->translator);
    }
141222
private function parse($body)
    {
        $xml = simplexml_load_string($body);

        $data = $xml->xpath('//soap:Body');

        $response = array();

        foreach ($data as $node) {
            $this->parseElement($response, $node);
        }

        return $response;
    }