1 | <?php |
||
18 | class ImpersonatorServiceProvider extends PackageServiceProvider implements DeferrableProvider |
||
19 | { |
||
20 | /* ----------------------------------------------------------------- |
||
21 | | Properties |
||
22 | | ----------------------------------------------------------------- |
||
23 | */ |
||
24 | |||
25 | /** |
||
26 | * Package name. |
||
27 | * |
||
28 | * @var string |
||
29 | */ |
||
30 | protected $package = 'impersonator'; |
||
31 | |||
32 | /* ----------------------------------------------------------------- |
||
33 | | Main Methods |
||
34 | | ----------------------------------------------------------------- |
||
35 | */ |
||
36 | |||
37 | /** |
||
38 | * Register the service provider. |
||
39 | */ |
||
40 | 112 | public function register(): void |
|
41 | { |
||
42 | 112 | parent::register(); |
|
43 | |||
44 | 112 | $this->registerConfig(); |
|
45 | |||
46 | 56 | $this->singleton(ImpersonatorContract::class, Impersonator::class); |
|
47 | 112 | $this->extendAuthDriver(); |
|
48 | 112 | } |
|
49 | |||
50 | /** |
||
51 | * Boot the service provider. |
||
52 | */ |
||
53 | 112 | public function boot(): void |
|
54 | { |
||
55 | 112 | if ($this->app->runningInConsole()) { |
|
56 | 112 | $this->publishConfig(); |
|
57 | } |
||
58 | 112 | } |
|
59 | |||
60 | /** |
||
61 | * Get the services provided by the provider. |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | 4 | public function provides(): array |
|
71 | |||
72 | /* ----------------------------------------------------------------- |
||
73 | | Other Methods |
||
74 | | ----------------------------------------------------------------- |
||
75 | */ |
||
76 | |||
77 | /** |
||
78 | * Extend the auth session driver. |
||
79 | */ |
||
80 | 112 | private function extendAuthDriver(): void |
|
106 | } |
||
107 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: