1 | <?php |
||
14 | class UserAuthenticator |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * @var \PDO PDO |
||
19 | */ |
||
20 | protected $pdo; |
||
21 | |||
22 | /** |
||
23 | * @var int Password hashing cost |
||
24 | * |
||
25 | * @todo Get the cost from a configuration class |
||
26 | */ |
||
27 | private $passwordHashingCost = 11; |
||
28 | |||
29 | /** |
||
30 | * UserAuthenticator constructor. |
||
31 | * |
||
32 | * @param \PDO $pdo |
||
33 | */ |
||
34 | public function __construct(\PDO $pdo) |
||
38 | |||
39 | /** |
||
40 | * Authenticate user object from cookie |
||
41 | * |
||
42 | * @param Cookie $cookie Cookie object |
||
43 | * |
||
44 | * @return User|null User if a user ID is sent in cookie |
||
|
|||
45 | */ |
||
46 | public function userFromCookie(Cookie $cookie): User |
||
64 | |||
65 | /** |
||
66 | * Sign in an user |
||
67 | * |
||
68 | * @param User $user User object |
||
69 | * @param string $password User password |
||
70 | * |
||
71 | * @return bool Returns true if sign in was successful, otherwise false will be returned |
||
72 | */ |
||
73 | public function signIn(User $user, string $password): bool |
||
119 | } |
||
120 |
This check looks for the generic type
array
as a return type and suggests a more specific type. This type is inferred from the actual code.