function RestLoginHttpTest::getResultValue
Same name and namespace in other branches
- 11.x core/modules/rest/tests/src/Functional/RestLoginHttpTest.php \Drupal\Tests\rest\Functional\RestLoginHttpTest::getResultValue()
Gets a value for a given key from the response.
Parameters
\Psr\Http\Message\ResponseInterface $response: The response object.
string $key: The key for the value.
string $format: The encoded format.
Return value
mixed The value for the key.
File
-
core/
modules/ rest/ tests/ src/ Functional/ RestLoginHttpTest.php, line 275
Class
- RestLoginHttpTest
- Tests login and password reset via direct HTTP.
Namespace
Drupal\Tests\rest\FunctionalCode
protected function getResultValue(ResponseInterface $response, string $key, string $format) : mixed {
$decoded = $this->serializer
->decode((string) $response->getBody(), $format);
if (is_array($decoded)) {
return $decoded[$key];
}
else {
return $decoded->{$key};
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.