1 | <?php |
||
10 | class JwtService |
||
11 | { |
||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | private $key; |
||
17 | |||
18 | /** |
||
19 | * @var TokenManager |
||
20 | */ |
||
21 | protected $tokenManager; |
||
22 | |||
23 | /** |
||
24 | * JwtService constructor |
||
25 | * |
||
26 | * @param TokenManager $tokenManager |
||
27 | */ |
||
28 | public function __construct(TokenManager $tokenManager) |
||
33 | |||
34 | /** |
||
35 | * getTokenForUser method |
||
36 | * |
||
37 | * @param Authenticatable $user |
||
38 | * @return null|string |
||
39 | */ |
||
40 | public function getTokenForUser(Authenticatable $user) |
||
48 | |||
49 | /** |
||
50 | * getUserIdFromToken method |
||
51 | * |
||
52 | * @param $token |
||
53 | * @return mixed|null |
||
54 | */ |
||
55 | public function getUserIdFromToken($token) |
||
65 | |||
66 | /** |
||
67 | * refreshToken method |
||
68 | * |
||
69 | * @param $token |
||
70 | * @return null|string |
||
71 | */ |
||
72 | public function refreshToken($token) |
||
88 | |||
89 | /** |
||
90 | * getTokenForUser method |
||
91 | * |
||
92 | * @param Claim $claim |
||
93 | * @return null|string |
||
94 | */ |
||
95 | protected function getTokenForClaim(Claim $claim) |
||
102 | |||
103 | /** |
||
104 | * getClaimFromToken method |
||
105 | * |
||
106 | * @param $token |
||
107 | * @return null|Claim |
||
108 | */ |
||
109 | protected function getClaimFromToken($token) |
||
120 | |||
121 | } |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: