1 | <?php |
||
19 | class ApiKeyAuthenticationHandler implements AuthenticationHandlerInterface |
||
20 | { |
||
21 | /** |
||
22 | * @var ObjectManager |
||
23 | */ |
||
24 | private $om; |
||
25 | |||
26 | /** |
||
27 | * @var PasswordHasherInterface |
||
28 | */ |
||
29 | private $passwordHasher; |
||
30 | |||
31 | /** |
||
32 | * @var KeyFactoryInterface |
||
33 | */ |
||
34 | private $keyFactory; |
||
35 | |||
36 | /** |
||
37 | * @var EventDispatcherInterface |
||
38 | */ |
||
39 | private $eventDispatcher; |
||
40 | |||
41 | /** |
||
42 | * @var string |
||
43 | */ |
||
44 | private $modelName; |
||
45 | |||
46 | /** |
||
47 | * @var ClassMetadata |
||
48 | */ |
||
49 | private $classMetadata; |
||
50 | |||
51 | /** |
||
52 | * Constructor. |
||
53 | * |
||
54 | * @param ObjectManager $om |
||
55 | * @param PasswordHasherInterface $passwordHasher |
||
56 | * @param KeyFactoryInterface $keyFactory |
||
57 | * @param EventDispatcherInterface $dispatcher |
||
58 | * @param string $modelName |
||
59 | * @param ClassMetadata $metadata |
||
60 | */ |
||
61 | 19 | public function __construct( |
|
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | * |
||
80 | * @throws \InvalidArgumentException If the `login` or `password` property is missing. |
||
81 | * @throws CredentialException If the credentials couldn't be validated. |
||
82 | */ |
||
83 | 17 | public function authenticate(array $credentials) |
|
121 | |||
122 | /** |
||
123 | * {@inheritdoc} |
||
124 | */ |
||
125 | 4 | public function removeSession($user, $purgeJob = false) |
|
139 | |||
140 | /** |
||
141 | * Getter for the object manager. |
||
142 | * |
||
143 | * @return ObjectManager |
||
144 | */ |
||
145 | protected function getOm() |
||
149 | |||
150 | /** |
||
151 | * Getter for the password hasher. |
||
152 | * |
||
153 | * @return PasswordHasherInterface |
||
154 | */ |
||
155 | protected function getPasswordHasher() |
||
159 | |||
160 | /** |
||
161 | * Getter for the key factory. |
||
162 | * |
||
163 | * @return KeyFactoryInterface |
||
164 | */ |
||
165 | protected function getKeyFactory() |
||
169 | |||
170 | /** |
||
171 | * Getter for the dispatcher. |
||
172 | * |
||
173 | * @return EventDispatcherInterface |
||
174 | */ |
||
175 | protected function getEventDispatcher() |
||
179 | |||
180 | /** |
||
181 | * Getter for the model name. |
||
182 | * |
||
183 | * @return string |
||
184 | */ |
||
185 | protected function getModelName() |
||
189 | |||
190 | /** |
||
191 | * @return ClassMetadata |
||
192 | */ |
||
193 | protected function getClassMetadata() |
||
197 | |||
198 | /** |
||
199 | * Simple helper which builds the API key and stores it in the user. |
||
200 | * |
||
201 | * @param object $userObject |
||
202 | */ |
||
203 | 10 | private function buildKey($userObject) |
|
215 | |||
216 | /** |
||
217 | * Simple helper which searches the ObjectManager by the given login parameter. |
||
218 | * |
||
219 | * @param string $loginProperty |
||
220 | * @param array $credentials |
||
221 | * |
||
222 | * @return object |
||
223 | */ |
||
224 | 15 | private function resolveObject($loginProperty, array $credentials) |
|
230 | |||
231 | /** |
||
232 | * Validates the existance of the object and ensures that a valid password is given. |
||
233 | * |
||
234 | * @param object $object |
||
235 | * @param string $password |
||
236 | * |
||
237 | * @return bool |
||
238 | */ |
||
239 | 15 | private function validateCredentials($object, $password) |
|
246 | |||
247 | /** |
||
248 | * Builds the `OnLogoutEvent`. |
||
249 | * |
||
250 | * @param object $user |
||
251 | * @param bool $purgeJob |
||
252 | * |
||
253 | * @return OnLogoutEvent |
||
254 | */ |
||
255 | 4 | private function buildEventObject($user, $purgeJob = false) |
|
264 | } |
||
265 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.