GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AwsS3Filesystem   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
c 2
b 0
f 0
lcom 1
cbo 4
dl 0
loc 82
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 16 4
B prepareAdapter() 0 23 4
1
<?php
2
/**
3
 * @link https://github.com/creocoder/yii2-flysystem
4
 * @copyright Copyright (c) 2015 Alexander Kochetov
5
 * @license http://opensource.org/licenses/BSD-3-Clause
6
 */
7
8
namespace creocoder\flysystem;
9
10
use Aws\S3\S3Client;
11
use League\Flysystem\AwsS3v3\AwsS3Adapter;
12
use yii\base\InvalidConfigException;
13
14
/**
15
 * AwsS3Filesystem
16
 *
17
 * @author Alexander Kochetov <[email protected]>
18
 */
19
class AwsS3Filesystem extends Filesystem
20
{
21
    /**
22
     * @var string
23
     */
24
    public $key;
25
    /**
26
     * @var string
27
     */
28
    public $secret;
29
    /**
30
     * @var string
31
     */
32
    public $region;
33
    /**
34
     * @var string
35
     */
36
    public $baseUrl;
37
    /**
38
     * @var string
39
     */
40
    public $version;
41
    /**
42
     * @var string
43
     */
44
    public $bucket;
45
    /**
46
     * @var string|null
47
     */
48
    public $prefix;
49
    /**
50
     * @var array
51
     */
52
    public $options = [];
53
54
    /**
55
     * @inheritdoc
56
     */
57
    public function init()
58
    {
59
        if ($this->key === null) {
60
            throw new InvalidConfigException('The "key" property must be set.');
61
        }
62
63
        if ($this->secret === null) {
64
            throw new InvalidConfigException('The "secret" property must be set.');
65
        }
66
67
        if ($this->bucket === null) {
68
            throw new InvalidConfigException('The "bucket" property must be set.');
69
        }
70
71
        parent::init();
72
    }
73
74
    /**
75
     * @return AwsS3Adapter
76
     */
77
    protected function prepareAdapter()
78
    {
79
        $config = [
80
            'credentials' => [
81
                'key' => $this->key,
82
                'secret' => $this->secret
83
            ]
84
        ];
85
86
        if ($this->region !== null) {
87
            $config['region'] = $this->region;
88
        }
89
90
        if ($this->baseUrl !== null) {
91
            $config['base_url'] = $this->baseUrl;
92
        }
93
94
        $config['version'] = (($this->version !== null) ? $this->version : 'latest');
95
96
        $client = new S3Client($config);
97
98
        return new AwsS3Adapter($client, $this->bucket, $this->prefix, $this->options);
99
    }
100
}
101