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

GoogleFactory::getFilesystemAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 10
rs 10
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