1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of Laravel Optimus. |
||
5 | * |
||
6 | * (c) Anton Komarev <[email protected]> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | declare(strict_types=1); |
||
13 | |||
14 | namespace Cog\Laravel\Optimus\Providers; |
||
15 | |||
16 | use Cog\Laravel\Optimus\OptimusFactory; |
||
17 | use Cog\Laravel\Optimus\OptimusManager; |
||
18 | use Illuminate\Contracts\Container\Container; |
||
19 | use Illuminate\Foundation\Application as LaravelApplication; |
||
20 | use Illuminate\Support\ServiceProvider; |
||
21 | use Jenssegers\Optimus\Optimus; |
||
22 | use Laravel\Lumen\Application as LumenApplication; |
||
23 | |||
24 | /** |
||
25 | * Class OptimusServiceProvider. |
||
26 | * |
||
27 | * @package Cog\Laravel\Optimus\Providers |
||
28 | */ |
||
29 | class OptimusServiceProvider extends ServiceProvider |
||
30 | { |
||
31 | /** |
||
32 | * Boot the service provider. |
||
33 | * |
||
34 | * @return void |
||
35 | */ |
||
36 | public function boot() |
||
37 | { |
||
38 | $this->setupConfig(); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Register the service provider. |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | public function register() |
||
47 | { |
||
48 | $this->bindFactory(); |
||
49 | $this->bindManager(); |
||
50 | $this->bindOptimus(); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * Get the services provided by the provider. |
||
55 | * |
||
56 | * @return string[] |
||
57 | */ |
||
58 | public function provides(): array |
||
59 | { |
||
60 | return [ |
||
61 | 'optimus', |
||
62 | 'optimus.factory', |
||
63 | 'optimus.connection', |
||
64 | ]; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * Setup the config. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | protected function setupConfig() |
||
73 | { |
||
74 | $source = realpath(__DIR__ . '/../../config/optimus.php'); |
||
75 | |||
76 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
||
77 | $this->publishes([$source => config_path('optimus.php')], 'config'); |
||
78 | } elseif ($this->app instanceof LumenApplication) { |
||
79 | $this->app->configure('optimus'); |
||
0 ignored issues
–
show
|
|||
80 | } |
||
81 | |||
82 | $this->mergeConfigFrom($source, 'optimus'); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * Register the factory class. |
||
87 | * |
||
88 | * @return void |
||
89 | */ |
||
90 | protected function bindFactory() |
||
91 | { |
||
92 | $this->app->singleton('optimus.factory', function () { |
||
93 | return new OptimusFactory; |
||
94 | }); |
||
95 | |||
96 | $this->app->alias('optimus.factory', OptimusFactory::class); |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Register the manager class. |
||
101 | * |
||
102 | * @return void |
||
103 | */ |
||
104 | protected function bindManager() |
||
105 | { |
||
106 | $this->app->singleton('optimus', function (Container $app) { |
||
107 | $config = $app['config']; |
||
108 | $factory = $app['optimus.factory']; |
||
109 | |||
110 | return new OptimusManager($config, $factory); |
||
111 | }); |
||
112 | |||
113 | $this->app->alias('optimus', OptimusManager::class); |
||
114 | } |
||
115 | |||
116 | /** |
||
117 | * Register the bindings. |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | protected function bindOptimus() |
||
122 | { |
||
123 | $this->app->bind('optimus.connection', function (Container $app) { |
||
124 | $manager = $app['optimus']; |
||
125 | |||
126 | return $manager->connection(); |
||
127 | }); |
||
128 | |||
129 | $this->app->alias('optimus.connection', Optimus::class); |
||
130 | } |
||
131 | } |
||
132 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.