1 | <?php |
||
15 | class ClientAuthentication |
||
16 | { |
||
17 | |||
18 | /** |
||
19 | * @var Callable |
||
20 | */ |
||
21 | public $cookie_getter; |
||
22 | |||
23 | /** |
||
24 | * @var Callable |
||
25 | */ |
||
26 | public $cookie_parser; |
||
27 | |||
28 | /** |
||
29 | * @var string |
||
30 | */ |
||
31 | public $cookie_name; |
||
32 | |||
33 | /** |
||
34 | * @var LoggerInterface |
||
35 | */ |
||
36 | public $logger; |
||
37 | |||
38 | |||
39 | /** |
||
40 | * Added to $status when cookie was found |
||
41 | */ |
||
42 | CONST FOUND = 1; |
||
43 | |||
44 | /** |
||
45 | * Added to $status when parsing succeeded |
||
46 | */ |
||
47 | CONST VALID = 2; |
||
48 | |||
49 | /** |
||
50 | * Hold status information |
||
51 | * @var integer |
||
52 | */ |
||
53 | public $status = 0; |
||
54 | |||
55 | /** |
||
56 | * @param Callable $cookie_getter Any callable that accepts a cookie name and returns its value |
||
57 | * @param Callable $cookie_parser Any callable that parses a cookie value into a selector and token pair |
||
58 | * @param string $cookie_name The permanent login cookie name |
||
59 | * @param LoggerInterface|null $logger Optional: PSR-3 Logger |
||
60 | */ |
||
61 | 15 | public function __construct( Callable $cookie_getter, Callable $cookie_parser, $cookie_name, LoggerInterface $logger = null) |
|
68 | |||
69 | |||
70 | |||
71 | /** |
||
72 | * Returns a selector and token pair like this: |
||
73 | * |
||
74 | * <?php |
||
75 | * $result = (object) [ |
||
76 | * 'selector' => 'foo', |
||
77 | * 'token' => 'fdskfkqrqgqfi4t2iq89fu3uf8fhq' |
||
78 | * ]; |
||
79 | * ?> |
||
80 | * |
||
81 | * If no cookie was sent along, or parsing failed, FALSE will be returned. |
||
82 | * |
||
83 | * @return mixed Success: StdClass object with selector and token or FALSE |
||
84 | */ |
||
85 | 15 | public function __invoke() |
|
120 | } |
||
121 |