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; |
||||||
0 ignored issues
–
show
|
|||||||
23 | |||||||
24 | class OptimusServiceProvider extends ServiceProvider |
||||||
25 | { |
||||||
26 | /** |
||||||
27 | * Boot the service provider. |
||||||
28 | */ |
||||||
29 | public function boot(): void |
||||||
30 | { |
||||||
31 | $this->setupConfig(); |
||||||
32 | } |
||||||
33 | |||||||
34 | /** |
||||||
35 | * Register the service provider. |
||||||
36 | */ |
||||||
37 | public function register(): void |
||||||
38 | { |
||||||
39 | $this->bindFactory(); |
||||||
40 | $this->bindManager(); |
||||||
41 | $this->bindOptimus(); |
||||||
42 | } |
||||||
43 | |||||||
44 | /** |
||||||
45 | * Get the services provided by the provider. |
||||||
46 | */ |
||||||
47 | public function provides(): array |
||||||
48 | { |
||||||
49 | return [ |
||||||
50 | 'optimus', |
||||||
51 | 'optimus.factory', |
||||||
52 | 'optimus.connection', |
||||||
53 | ]; |
||||||
54 | } |
||||||
55 | |||||||
56 | /** |
||||||
57 | * Setup the config. |
||||||
58 | */ |
||||||
59 | protected function setupConfig(): void |
||||||
60 | { |
||||||
61 | $source = realpath(__DIR__ . '/../../config/optimus.php'); |
||||||
62 | |||||||
63 | if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) { |
||||||
64 | $this->publishes([$source => config_path('optimus.php')], 'config'); |
||||||
65 | } elseif ($this->app instanceof LumenApplication) { |
||||||
66 | $this->app->configure('optimus'); |
||||||
0 ignored issues
–
show
The method
configure() does not exist on Illuminate\Contracts\Foundation\Application . Did you maybe mean configPath() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
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. ![]() |
|||||||
67 | } |
||||||
68 | |||||||
69 | $this->mergeConfigFrom($source, 'optimus'); |
||||||
70 | } |
||||||
71 | |||||||
72 | /** |
||||||
73 | * Register the factory class. |
||||||
74 | */ |
||||||
75 | protected function bindFactory(): void |
||||||
76 | { |
||||||
77 | $this->app->singleton('optimus.factory', function () { |
||||||
78 | return new OptimusFactory(); |
||||||
79 | }); |
||||||
80 | |||||||
81 | $this->app->alias('optimus.factory', OptimusFactory::class); |
||||||
82 | } |
||||||
83 | |||||||
84 | /** |
||||||
85 | * Register the manager class. |
||||||
86 | */ |
||||||
87 | protected function bindManager(): void |
||||||
88 | { |
||||||
89 | $this->app->singleton('optimus', function (Container $app) { |
||||||
90 | $config = $app['config']; |
||||||
91 | $factory = $app['optimus.factory']; |
||||||
92 | |||||||
93 | return new OptimusManager($config, $factory); |
||||||
94 | }); |
||||||
95 | |||||||
96 | $this->app->alias('optimus', OptimusManager::class); |
||||||
97 | } |
||||||
98 | |||||||
99 | /** |
||||||
100 | * Register the bindings. |
||||||
101 | */ |
||||||
102 | protected function bindOptimus(): void |
||||||
103 | { |
||||||
104 | $this->app->bind('optimus.connection', function (Container $app) { |
||||||
105 | $manager = $app['optimus']; |
||||||
106 | |||||||
107 | return $manager->connection(); |
||||||
108 | }); |
||||||
109 | |||||||
110 | $this->app->alias('optimus.connection', Optimus::class); |
||||||
111 | } |
||||||
112 | } |
||||||
113 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths