You are here

public function ServerRequest::getAttribute in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/zendframework/zend-diactoros/src/ServerRequest.php \Zend\Diactoros\ServerRequest::getAttribute()
  2. 8.0 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest::getAttribute()
Same name and namespace in other branches
  1. 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\ServerRequest::getAttribute()

Retrieve a single derived request attribute.

Retrieves a single derived request attribute as described in getAttributes(). If the attribute has not been previously set, returns the default value as provided.

This method obviates the need for a hasAttribute() method, as it allows specifying a default value to return if the attribute is not found.

Parameters

string $name The attribute name.:

mixed $default Default value to return if the attribute does not exist.:

Return value

mixed

Overrides ServerRequestInterface::getAttribute

See also

getAttributes()

File

vendor/symfony/psr-http-message-bridge/Tests/Fixtures/ServerRequest.php, line 127

Class

ServerRequest
@author Kévin Dunglas <dunglas@gmail.com>

Namespace

Symfony\Bridge\PsrHttpMessage\Tests\Fixtures

Code

public function getAttribute($name, $default = null) {
  return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
}