Completed
Pull Request — master (#3)
by
unknown
02:10
created

AzureAdapterFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11FlySystem\Adaptor;
5
6
use League\Flysystem\Azure\AzureAdapter;
7
use MicrosoftAzure\Storage\Common\ServicesBuilder;
8
use WShafer\PSR11FlySystem\FactoryInterface;
9
10
class AzureAdapterFactory implements FactoryInterface
11
{
12
    public function __invoke(array $options)
13
    {
14
        $accountName = $options['accountName'] ?? null;
15
        $apiKey = $options['apiKey'] ?? null;
16
        $container = $options['container'] ?? null;
17
        $prefix = $options['prefix'] ?? null;
18
19
        $endpoint = sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $accountName, $apiKey);
20
21
        $proxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
22
        return new AzureAdapter($proxy, $container, $prefix);
23
    }
24
}
25