Symfony\Component\Security\Core\Authentication\Token\AbstractToken::getAttribute PHP Method

getAttribute() public method

Returns an attribute value.
public getAttribute ( string $name ) : mixed
$name string The attribute name
return mixed The attribute value
    public function getAttribute($name)
    {
        if (!array_key_exists($name, $this->attributes)) {
            throw new \InvalidArgumentException(sprintf('This token has no "%s" attribute.', $name));
        }

        return $this->attributes[$name];
    }

Usage Example

 /**
  * Returns an attribute as an array of values
  * @param string $name
  * @return array
  */
 public function getArrayAttribute($name)
 {
     $value = parent::getAttribute($name);
     return is_array($value) ? $value : array($value);
 }