Passed
Push — master ( fe35f4...b5dd62 )
by Jared
02:05
created

DropboxAdapter::getUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AnyCloud\Service\File\Adapter;
4
5
use AnyCloud\Traits\CommonTrait;
6
use Spatie\Dropbox\Client;
7
use Spatie\FlysystemDropbox\DropboxAdapter as FlyDropboxAdapter;
8
use Omeka\File\Exception\ConfigException;
1 ignored issue
show
Bug introduced by
The type Omeka\File\Exception\ConfigException 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...
9
10
class DropboxAdapter implements AdapterInterface
11
{
12
    use CommonTrait;
13
14
    protected $options;
15
    private $client;
16
17
    /**
18
     * {@inheritDoc}
19
     */
20
    public function createAdapter($options)
21
    {
22
        $this->options = $options;
23
        $this->createClient();
24
25
        return new FlyDropboxAdapter($this->client);
26
    }
27
28
    /**
29
     * Find the public base URI for the resource
30
     *
31
     * This is actually generated on the fly in `AnyCloudFactory.php`
32
     * because all Dropbox URIs are temporary and expire
33
     *
34
     * return string Base URL for the resource
35
     */
36
    public function getUri()
37
    {
38
        return null;
39
    }
40
41
    /**
42
     * Create client
43
     */
44
    private function createClient()
45
    {
46
        $this->optionExists('access_token');
47
48
        try {
49
            $this->client = new Client($this->getSetting('access_token'));
0 ignored issues
show
Bug introduced by
It seems like $this->getSetting('access_token') can also be of type null; however, parameter $accessToken of Spatie\Dropbox\Client::__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

49
            $this->client = new Client(/** @scrutinizer ignore-type */ $this->getSetting('access_token'));
Loading history...
50
        } catch (ConfigException $e) {
51
            echo 'Dropbox Error: '.$e->getMessage()."\n";
52
        }
53
    }
54
}
55