Conditions | 4 |
Paths | 4 |
Total Lines | 13 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php namespace nyx\auth\signers; |
||
25 | public function sign(string $payload, $key) : string |
||
26 | { |
||
27 | if ($key instanceof auth\interfaces\Credentials) { |
||
28 | $key = $key->getSecret(); |
||
29 | } |
||
30 | |||
31 | // At this point we expect to have a non-empty string as the key. |
||
32 | if (!is_string($key) || empty($key)) { |
||
33 | throw new \InvalidArgumentException('Invalid signing key provided.'); |
||
34 | } |
||
35 | |||
36 | return hash_hmac($this->getAlgorithm(), $payload, $key, true); |
||
37 | } |
||
38 | |||
47 |