1 | <?php |
||
29 | abstract class AbstractAdapter implements \Caridea\Auth\Adapter |
||
30 | { |
||
31 | /** |
||
32 | * Checks that a string argument isn't null, empty, or just whitespace. |
||
33 | * |
||
34 | * @param string $object The value to check for blankness |
||
35 | * @param string $fieldName The name of the parameter (for Exception message) |
||
36 | * @return mixed Returns `$object` |
||
37 | * @throws \InvalidArgumentException if the value is null, empty, or whitespace |
||
38 | */ |
||
39 | 15 | protected function checkBlank($object, string $fieldName) |
|
46 | |||
47 | /** |
||
48 | * Throws a `MissingCredentials` if the value is empty. |
||
49 | * |
||
50 | * @param array $source The params array |
||
51 | * @param string $key The array offset |
||
52 | * @return mixed Returns the value of `$source[$key]` |
||
53 | * @throws \Caridea\Auth\Exception\MissingCredentials If `$source[$key]` is empty |
||
54 | */ |
||
55 | 14 | protected function ensure(array &$source, string $key) |
|
62 | |||
63 | /** |
||
64 | * Verifies a user-provided password against a hash. |
||
65 | * |
||
66 | * @param string $input The user-provided password |
||
67 | * @param string $hash The stored password hash |
||
68 | * @throws \Caridea\Auth\Exception\MissingCredentials If the user-provided password is empty |
||
69 | * @throws \Caridea\Auth\Exception\InvalidPassword If the password fails to verify |
||
70 | */ |
||
71 | 4 | protected function verify(string $input, string $hash) |
|
77 | |||
78 | /** |
||
79 | * Gets a default set of details for web requests (includes User-Agent and IP). |
||
80 | * |
||
81 | * ```php |
||
82 | * $details = $this->details($request, ['foo' => 'bar']) |
||
83 | * // $details = [ |
||
84 | * // 'ua' => 'My User Agent/1.0', |
||
85 | * // 'ip' => '127.0.0.1', |
||
86 | * // 'foo' => 'bar' |
||
87 | * // ] |
||
88 | * |
||
89 | * ``` |
||
90 | * |
||
91 | * @param \Psr\Http\Message\ServerRequestInterface $request The server request |
||
92 | * @param array $details Any details to add |
||
93 | * @return array The details |
||
94 | */ |
||
95 | 4 | protected function details(\Psr\Http\Message\ServerRequestInterface $request, array $details): array |
|
103 | } |
||
104 |