AzureFactory::getFilesystemAdapter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace AnyCloud\Service\File\Store;
4
5
use League\Flysystem\AzureBlobStorage\AzureBlobStorageAdapter;
6
use League\Flysystem\FilesystemAdapter;
7
use MicrosoftAzure\Storage\Blob\BlobRestProxy;
8
9
class AzureFactory extends AbstractFlysystemFactory
10
{
11
    protected function getConfigKey(): string
12
    {
13
        return 'azure';
14
    }
15
16
    protected function getFilesystemAdapter(array $config): FilesystemAdapter
17
    {
18
        $connectionString = sprintf(
19
            'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;',
20
            $config['account_name'],
21
            $config['account_key']
22
        );
23
        $client = BlobRestProxy::createBlobService($connectionString);
24
        $adapter = new AzureBlobStorageAdapter($client, $config['container_name']);
25
26
        return $adapter;
27
    }
28
}
29