You are here

public function ServerRequest::getAttribute in Auth0 Single Sign On 8.2

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/guzzlehttp/psr7/src/ServerRequest.php, line 342

Class

ServerRequest
Server-side HTTP request

Namespace

GuzzleHttp\Psr7

Code

public function getAttribute($attribute, $default = null) {
  if (false === array_key_exists($attribute, $this->attributes)) {
    return $default;
  }
  return $this->attributes[$attribute];
}