1 | <?php |
||
12 | class ExpoPushNotificationsServiceProvider extends ServiceProvider |
||
13 | { |
||
14 | /** |
||
15 | * Bootstrap the application services. |
||
16 | * |
||
17 | * @return void |
||
18 | */ |
||
19 | 23 | public function boot() |
|
20 | { |
||
21 | 23 | $this->setupConfig(); |
|
22 | |||
23 | 23 | $repository = $this->getInterestsDriver(); |
|
24 | |||
25 | 23 | $this->shouldPublishMigrations($repository); |
|
|
|||
26 | |||
27 | 23 | $this->app->when(ExpoChannel::class) |
|
28 | 23 | ->needs(Expo::class) |
|
29 | ->give(function () use ($repository) { |
||
30 | return new Expo(new ExpoRegistrar($repository)); |
||
31 | 23 | }); |
|
32 | |||
33 | 23 | $this->loadRoutesFrom(__DIR__.'/Http/routes.php'); |
|
34 | 23 | } |
|
35 | |||
36 | /** |
||
37 | * Register the application services. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 23 | public function register() |
|
45 | |||
46 | /** |
||
47 | * Gets the Expo repository driver based on config. |
||
48 | * |
||
49 | * @return ExpoRepository |
||
50 | */ |
||
51 | 23 | public function getInterestsDriver() |
|
52 | { |
||
53 | 23 | $driver = config('exponent-push-notifications.interests.driver'); |
|
54 | |||
55 | 23 | switch ($driver) { |
|
56 | 23 | case 'database': |
|
57 | return new ExpoDatabaseDriver(); |
||
58 | break; |
||
59 | default: |
||
60 | 23 | return new ExpoFileDriver(); |
|
61 | } |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Publishes the configuration files for the package. |
||
66 | * |
||
67 | * @return void |
||
68 | */ |
||
69 | 23 | protected function setupConfig() |
|
77 | |||
78 | /** |
||
79 | * Publishes the migration files needed in the package. |
||
80 | * |
||
81 | * @param ExpoRepository $repository |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | 23 | private function shouldPublishMigrations(ExpoRepository $repository) |
|
94 | } |
||
95 |
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.