AzureAdapterFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 1
crap 1
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('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s', $accountName, $apiKey);
20
21 1
        $proxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
22 1
        return new AzureAdapter($proxy, $container, $prefix);
23
    }
24
}
25