RestContext::saveFieldValueUnderLocation PHP Метод

saveFieldValueUnderLocation() публичный Метод

public saveFieldValueUnderLocation ( string $fieldName, string $locationIndex ) : Behat\Behat\Context\Step\Then | void
$fieldName string
$locationIndex string
Результат Behat\Behat\Context\Step\Then | void
    public function saveFieldValueUnderLocation($fieldName, $locationIndex)
    {
        $this->response = $this->client->getLastResponse();
        $fieldValue = null;
        if ($this->responseIsJson) {
            if ($this->associative) {
                if (!is_array($this->responseData) || !array_key_exists($fieldName, $this->responseData)) {
                    throw new \Exception('Field "' . $fieldName . '" is not set!');
                }
                $fieldValue = $this->responseData[$fieldName];
            } else {
                if (!$this->responseData instanceof stdClass || !property_exists($this->responseData, $name)) {
                    throw new \Exception('Field "' . $fieldName . '" is not set!');
                }
                $fieldValue = $this->responseData->{$fieldName};
            }
            $this->locations[$locationIndex] = $fieldValue;
        } else {
            return new Step\Then('the response is JSON');
        }
    }