| 1 | <?php |
||
| 11 | class UsernameAndPasswordToken implements TokenInterface |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * @var string |
||
| 15 | */ |
||
| 16 | private $username; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $password; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * UsernameAndPasswordToken constructor. |
||
| 25 | * |
||
| 26 | * @param string $username |
||
| 27 | * @param string $password |
||
| 28 | * |
||
| 29 | * @throws \InvalidArgumentException |
||
| 30 | */ |
||
| 31 | 5 | public function __construct($username, $password) |
|
| 32 | { |
||
| 33 | 5 | if (empty($username) || !is_string($username)) { |
|
| 34 | 1 | throw new InvalidArgumentException( |
|
| 35 | 1 | sprintf('Please provide username in %s', get_class($this)) |
|
| 36 | 1 | ); |
|
| 37 | } |
||
| 38 | 5 | $this->username = $username; |
|
| 39 | |||
| 40 | 5 | if (empty($password) || !is_string($password)) { |
|
| 41 | 1 | throw new InvalidArgumentException( |
|
| 42 | 1 | sprintf('Please provide password in %s', get_class($this)) |
|
| 43 | 1 | ); |
|
| 44 | } |
||
| 45 | 5 | $this->password = $password; |
|
| 46 | 5 | } |
|
| 47 | |||
| 48 | /** |
||
| 49 | * {@inheritdoc} |
||
| 50 | */ |
||
| 51 | 1 | public function getAuthentication() |
|
| 55 | } |
||
| 56 |