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

GoogleFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfigKey() 0 3 1
A getFilesystemAdapter() 0 10 1
1
<?php
2
3
namespace AnyCloud\Service\File\Store;
4
5
use Google\Cloud\Storage\StorageClient;
6
use League\Flysystem\FilesystemAdapter;
7
use League\Flysystem\GoogleCloudStorage\GoogleCloudStorageAdapter;
8
9
class GoogleFactory extends AbstractFlysystemFactory
10
{
11
    protected function getConfigKey(): string
12
    {
13
        return 'google';
14
    }
15
16
    protected function getFilesystemAdapter(array $config): FilesystemAdapter
17
    {
18
        $client = new StorageClient([
19
            'projectId'   => $config['project_id'],
20
            'keyFilePath' => sprintf('%s/modules/AnyCloud%s', OMEKA_PATH, $config['credentials_path']),
0 ignored issues
show
Bug introduced by
The constant AnyCloud\Service\File\Store\OMEKA_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
21
        ]);
22
        $bucket = $client->bucket($config['bucket_name']);
23
        $adapter = new GoogleCloudStorageAdapter($bucket);
24
25
        return $adapter;
26
    }
27
}
28