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.

RackspaceFilesystem   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 7
c 2
b 0
f 0
lcom 1
cbo 5
dl 0
loc 69
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 24 6
A prepareAdapter() 0 10 1
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 League\Flysystem\Rackspace\RackspaceAdapter;
11
use OpenCloud\Rackspace;
12
use yii\base\InvalidConfigException;
13
14
/**
15
 * RackspaceFilesystem
16
 *
17
 * @author Alexander Kochetov <[email protected]>
18
 */
19
class RackspaceFilesystem extends Filesystem
20
{
21
    /**
22
     * @var string
23
     */
24
    public $endpoint;
25
    /**
26
     * @var string
27
     */
28
    public $username;
29
    /**
30
     * @var string
31
     */
32
    public $apiKey;
33
    /**
34
     * @var string
35
     */
36
    public $region;
37
    /**
38
     * @var string
39
     */
40
    public $container;
41
    /**
42
     * @var string|null
43
     */
44
    public $prefix;
45
46
    /**
47
     * @inheritdoc
48
     */
49
    public function init()
50
    {
51
        if ($this->endpoint === null) {
52
            throw new InvalidConfigException('The "endpoint" property must be set.');
53
        }
54
55
        if ($this->username === null) {
56
            throw new InvalidConfigException('The "username" property must be set.');
57
        }
58
59
        if ($this->apiKey === null) {
60
            throw new InvalidConfigException('The "apiKey" property must be set.');
61
        }
62
63
        if ($this->region === null) {
64
            throw new InvalidConfigException('The "region" property must be set.');
65
        }
66
67
        if ($this->container === null) {
68
            throw new InvalidConfigException('The "container" property must be set.');
69
        }
70
71
        parent::init();
72
    }
73
74
    /**
75
     * @return RackspaceAdapter
76
     */
77
    protected function prepareAdapter()
78
    {
79
        return new RackspaceAdapter(
80
            (new Rackspace($this->endpoint, [
81
                'username' => $this->username,
82
                'apiKey' => $this->apiKey]
83
            ))->objectStoreService('cloudFiles', $this->region)->getContainer($this->container),
0 ignored issues
show
Documentation introduced by
$this->container is of type string, but the function expects a object<stdClass>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
84
            $this->prefix
85
        );
86
    }
87
}
88