| 1 |
<?php |
| 2 |
|
| 3 |
namespace Intervention\HttpAuth\Token; |
| 4 |
|
| 5 |
use Intervention\HttpAuth\Exception\AuthentificationException; |
| 6 |
use Intervention\HttpAuth\Key; |
| 7 |
use Intervention\HttpAuth\TokenInterface; |
| 8 |
|
| 9 |
class NullToken implements TokenInterface |
| 10 |
{ |
| 11 |
/** |
| 12 |
* Create new instance |
| 13 |
*/ |
| 14 |
public function __construct() |
| 15 |
{ |
| 16 |
if ($this->parse() === false) { |
| 17 |
throw new AuthentificationException('Failed to parse token'); |
| 18 |
} |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Transform current instance to key object |
| 23 |
* |
| 24 |
* @return Key |
| 25 |
*/ |
| 26 |
public function toKey(): Key |
| 27 |
{ |
| 28 |
return new Key(); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Parse environment variables and store value in object |
| 33 |
* |
| 34 |
* @return bool "true" if value was found or "false" |
| 35 |
*/ |
| 36 |
protected function parse(): bool |
| 37 |
{ |
| 38 |
return true; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Return the value of given key in given array data. |
| 43 |
* Returns null if key doesn't exists |
| 44 |
* |
| 45 |
* @param array $data |
| 46 |
* @param mixed $key |
| 47 |
* @return mixed |
| 48 |
*/ |
| 49 |
protected function getArrayValue($data, $key) |
| 50 |
{ |
| 51 |
if (array_key_exists($key, $data)) { |
| 52 |
return $data[$key]; |
| 53 |
} |
| 54 |
|
| 55 |
return null; |
| 56 |
} |
| 57 |
} |
| 58 |
|