| Conditions | 6 |
| Paths | 10 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 6 | final public function __invoke($tokenString) |
|
| 25 | { |
||
| 26 | 6 | $token = (new Parser())->parse((string) $tokenString); |
|
| 27 | 6 | $signer = new Sha256(); |
|
| 28 | 6 | if (!$token->verify($signer, $this->config['secret'])) { |
|
| 29 | 1 | return false; |
|
| 30 | } |
||
| 31 | 5 | if (!$this->checkRequiredClaims(array_keys($token->getClaims()))) { |
|
| 32 | 1 | return false; |
|
| 33 | 4 | }; |
|
| 34 | 4 | $data = new ValidationData(); |
|
| 35 | 4 | if (isset($this->config['issuer'])) { |
|
| 36 | 4 | $data->setIssuer($this->config['issuer']); |
|
| 37 | 4 | } |
|
| 38 | 4 | if (isset($this->config['audience'])) { |
|
| 39 | 1 | $data->setAudience($this->config['audience']); |
|
| 40 | 1 | } |
|
| 41 | 4 | if (!$token->validate($data)) { |
|
| 42 | 2 | return false; |
|
| 43 | } |
||
| 44 | 2 | return $token; |
|
| 45 | } |
||
| 46 | } |
||
| 47 |