Completed
Push — master ( cd9d2f...0e5f81 )
by Westin
05:20
created

AzureAdapterFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1.0007

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 10
cts 11
cp 0.9091
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
crap 1.0007
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 1
    public function __invoke(array $options)
13
    {
14 1
        $accountName = $options['accountName'] ?? null;
15 1
        $apiKey = $options['apiKey'] ?? null;
16 1
        $container = $options['container'] ?? null;
17 1
        $prefix = $options['prefix'] ?? null;
18
19 1
        $endpoint = sprintf(
20 1
            'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
21
            $accountName,
22 1
            $apiKey
23
        );
24
25 1
        $proxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
26 1
        return new AzureAdapter($proxy, $container, $prefix);
27
    }
28
}
29