Passed
Push — master ( d2a5be...42531d )
by Jared
02:39 queued 13s
created

DropboxFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getStore() 0 7 1
A getFilesystemAdapter() 0 6 1
A getConfigKey() 0 3 1
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