AliOssServiceProvider   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 11
Bugs 0 Features 3
Metric Value
eloc 21
c 11
b 0
f 3
dl 0
loc 62
rs 10
wmc 9

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 2 1
B boot() 0 44 8
1
<?php
2
3
namespace Jacobcyl\AliOSS;
4
5
use Jacobcyl\AliOSS\Plugins\PutFile;
6
use Jacobcyl\AliOSS\Plugins\PutRemoteFile;
7
use Jacobcyl\AliOSS\Plugins\SignUrl;
8
use Jacobcyl\AliOSS\Plugins\GetProcessUrl;
9
use Illuminate\Support\Facades\Storage;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Storage 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...
10
use Illuminate\Support\Facades\Log;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Log 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...
11
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...
12
use League\Flysystem\Filesystem;
0 ignored issues
show
Bug introduced by
The type League\Flysystem\Filesystem 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 OSS\OssClient;
14
15
class AliOssServiceProvider extends ServiceProvider
16
{
17
18
    /**
19
     * Bootstrap the application services.
20
     *
21
     * @return void
22
     */
23
    public function boot()
24
    {
25
        //发布配置文件
26
        /*
27
        if (function_exists('config_path')) {
28
            $this->publishes([
29
                __DIR__ . '/config/config.php' => config_path('alioss.php'),
30
            ], 'config');
31
        }
32
        */
33
34
        Storage::extend('oss', function($app, $config)
35
        {
36
            $accessId  = $config['access_id'];
37
            $accessKey = $config['access_key'];
38
39
            $cdnDomain = empty($config['cdnDomain']) ? '' : $config['cdnDomain'];
40
            $bucket    = $config['bucket'];
41
            $ssl       = empty($config['ssl']) ? false : $config['ssl'];
42
            $isCname   = empty($config['isCName']) ? false : $config['isCName'];
43
            $securityToken = empty($config['securityToken']) ? null : $config['securityToken'];
44
            $debug     = empty($config['debug']) ? false : $config['debug'];
45
46
            $endPoint  = $config['endpoint']; // 默认作为外部节点
47
            // $epInternal= $isCname?$cdnDomain:(empty($config['endpoint_internal']) ? $endPoint : $config['endpoint_internal']); // 内部节点
48
            $epInternal= (empty($config['endpoint_internal']) ? $endPoint : $config['endpoint_internal']); // 内部节点
49
            
50
            if($debug) Log::debug('OSS config:', $config);
51
52
            $client  = new OssClient($accessId, $accessKey, $epInternal, $isCname, $securityToken);
53
            $adapter = new AliOssAdapter($client, $bucket, $endPoint, $ssl, $isCname, $debug, $cdnDomain);
54
55
            //Log::debug($client);
56
            $filesystem =  new Filesystem($adapter);
57
58
            $filesystem->addPlugin(new PutFile());
59
            $filesystem->addPlugin(new PutRemoteFile());
60
            //增加使用签名URL进行临时授权
61
            $filesystem->addPlugin(new SignUrl());
62
63
            //增加图片处理的方法
64
            $filesystem->addPlugin(new GetProcessUrl());
65
            //$filesystem->addPlugin(new CallBack());
66
            return $filesystem;
67
        });
68
    }
69
70
    /**
71
     * Register the application services.
72
     *
73
     * @return void
74
     */
75
    public function register()
76
    {
77
    }
78
79
}
80