Passed
Pull Request — master (#42)
by
unknown
08:12 queued 05:35
created

DropboxFactory::getFilesystemAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 10
1
<?php
2
3
namespace AnyCloud\Service\File\Store;
4
5
use AnyCloud\File\Store\Dropbox;
6
use AnyCloud\FilesystemAdapter\DropboxAdapter;
7
use League\Flysystem\Filesystem;
8
use League\Flysystem\FilesystemAdapter;
9
use Omeka\File\Store\StoreInterface;
10
use Spatie\Dropbox\Client;
11
12
class DropboxFactory extends AbstractFlysystemFactory
13
{
14
    protected function getConfigKey(): string
15
    {
16
        return 'dropbox';
17
    }
18
19
    protected function getFilesystemAdapter(array $config): FilesystemAdapter
20
    {
21
        $client = new Client($config['access_token']);
22
        $adapter = new DropboxAdapter($client);
23
24
        return $adapter;
25
    }
26
27
    protected function getStore(array $config): StoreInterface
28
    {
29
        $adapter = $this->getFilesystemAdapter($config);
30
        $filesystem = new Filesystem($adapter);
31
        $store = new Dropbox($filesystem);
32
33
        return $store;
34
    }
35
}
36