Passed
Pull Request — master (#54)
by
unknown
02:26
created

OssStorageServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 23
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 2 1
A boot() 0 28 3
1
<?php
2
3
namespace Jason\Flysystem\Oss;
4
5
use Jason\Flysystem\Oss\Plugins\FileUrl;
6
use Jason\Flysystem\Oss\Plugins\Kernel;
7
use Jason\Flysystem\Oss\Plugins\SetBucket;
8
use Jason\Flysystem\Oss\Plugins\SignatureConfig;
9
use Jason\Flysystem\Oss\Plugins\SignUrl;
10
use Jason\Flysystem\Oss\Plugins\TemporaryUrl;
11
use Jason\Flysystem\Oss\Plugins\Verify;
12
use Illuminate\Support\ServiceProvider;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\ServiceProvider 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...
13
use League\Flysystem\Filesystem;
14
15
/**
16
 * Class OssStorageServiceProvider
17
 * @author iidestiny <[email protected]>
18
 */
19
class OssStorageServiceProvider extends ServiceProvider
20
{
21
22
    /**
23
     * Bootstrap the application services.
24
     * @return void
25
     */
26
    public function boot()
27
    {
28
        app('filesystem')->extend('oss', function ($app, $config) {
0 ignored issues
show
Bug introduced by
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

28
        /** @scrutinizer ignore-call */ 
29
        app('filesystem')->extend('oss', function ($app, $config) {
Loading history...
29
            $root    = $config['root'] ?? null;
30
            $buckets = isset($config['buckets']) ? $config['buckets'] : [];
31
            $cdnHost = isset($config['cdnHost']) ? $config['cdnHost'] : '';
32
            $adapter = new OssAdapter(
33
                $config['access_key'],
34
                $config['secret_key'],
35
                $config['endpoint'],
36
                $config['bucket'],
37
                $config['isCName'],
38
                $root,
0 ignored issues
show
Bug introduced by
It seems like $root can also be of type null; however, parameter $prefix of Jason\Flysystem\Oss\OssAdapter::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

38
                /** @scrutinizer ignore-type */ $root,
Loading history...
39
                $buckets,
40
                $cdnHost
41
            );
42
43
            $filesystem = new Filesystem($adapter);
44
45
            $filesystem->addPlugin(new FileUrl());
46
            $filesystem->addPlugin(new SignUrl());
47
            $filesystem->addPlugin(new TemporaryUrl());
48
            $filesystem->addPlugin(new SignatureConfig());
49
            $filesystem->addPlugin(new SetBucket());
50
            $filesystem->addPlugin(new Verify());
51
            $filesystem->addPlugin(new Kernel());
52
53
            return $filesystem;
54
        });
55
    }
56
57
    /**
58
     * Register the application services.
59
     * @return void
60
     */
61
    public function register()
62
    {
63
        //
64
    }
65
66
}
67