Issues (59)

src/ChunkyServiceProvider.php (5 issues)

Labels
Severity
1
<?php
2
3
namespace Jobtech\LaravelChunky;
4
5
use Illuminate\Contracts\Container\Container;
6
use Illuminate\Contracts\Filesystem\Factory;
7
use Illuminate\Foundation\Application as LaravelApplication;
0 ignored issues
show
The type Illuminate\Foundation\Application was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Support\ServiceProvider;
9
use Jobtech\LaravelChunky\Commands\ClearChunks;
10
use Jobtech\LaravelChunky\Contracts\ChunkyManager as ChunkyManagerContract;
11
use Jobtech\LaravelChunky\Support\ChunksFilesystem;
12
use Jobtech\LaravelChunky\Support\MergeFilesystem;
13
use Jobtech\LaravelChunky\Support\TempFilesystem;
14
use Laravel\Lumen\Application as LumenApplication;
0 ignored issues
show
The type Laravel\Lumen\Application was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
class ChunkyServiceProvider extends ServiceProvider
17
{
18
    /**
19
     * Boot the application services.
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        $this->setupConfig();
26
    }
27
28
    /**
29
     * Register any application services.
30
     *
31
     * @return void
32
     */
33
    public function register()
34
    {
35
        $this->registerBindings();
36
        $this->registerCommands();
37
38
        $this->app->alias(ChunkyManagerContract::class, 'chunky');
39
    }
40
41
    protected function setupConfig()
42
    {
43
        $source = realpath(__DIR__.'/../config/chunky.php');
44
45
        if ($this->app instanceof LaravelApplication) {
46
            $this->publishes([
47
                $source => config_path('chunky.php'),
0 ignored issues
show
The function config_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

47
                $source => /** @scrutinizer ignore-call */ config_path('chunky.php'),
Loading history...
48
            ], 'config');
49
        } elseif ($this->app instanceof LumenApplication) {
50
            $this->app->configure('chunky');
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 ignore-call  annotation

50
            $this->app->/** @scrutinizer ignore-call */ 
51
                        configure('chunky');

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.

Loading history...
51
        }
52
53
        $this->mergeConfigFrom($source, 'chunky');
54
    }
55
56
    private function registerCommands()
57
    {
58
        $this->app->bind('command.chunky:clear', ClearChunks::class);
59
60
        $this->commands([
61
            'command.chunky:clear',
62
        ]);
63
    }
64
65
    private function registerBindings()
66
    {
67
        $this->app->singleton(TempFilesystem::class, function () {
68
            $config = $this->app->make('config');
69
            $filesystem = new TempFilesystem(app()->make(Factory::class));
0 ignored issues
show
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

69
            $filesystem = new TempFilesystem(/** @scrutinizer ignore-call */ app()->make(Factory::class));
Loading history...
70
71
            $filesystem->disk($config->get('chunky.disks.tmp.disk', $config->get('filesystems.default')));
72
            $filesystem->folder($config->get('chunky.disks.tmp.folder'));
73
74
            return $filesystem;
75
        });
76
77
        $this->app->bind(ChunksFilesystem::class, ChunksFilesystem::class);
78
        $this->app->bind(MergeFilesystem::class, MergeFilesystem::class);
79
80
        $this->app->singleton(ChunkySettings::class, function (Container $app) {
81
            return new ChunkySettings($app->make('config'));
82
        });
83
84
        $this->app->singleton(ChunkyManagerContract::class, function (Container $app) {
85
            return new ChunkyManager($app->make(ChunkySettings::class));
86
        });
87
    }
88
}
89