S3AdapterFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 13
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 13
cts 13
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace WShafer\PSR11FlySystem\Adaptor;
5
6
use Aws\S3\S3Client;
7
use League\Flysystem\AwsS3v3\AwsS3Adapter;
8
use WShafer\PSR11FlySystem\FactoryInterface;
9
10
class S3AdapterFactory implements FactoryInterface
11
{
12 1
    public function __invoke(array $options)
13
    {
14 1
        $key = $options['key'] ?? null;
15 1
        $secret = $options['secret'] ?? null;
16 1
        $region = $options['region'] ?? 'us-east-1';
17 1
        $version = $options['version'] ?? 'latest';
18 1
        $bucket = $options['bucket'] ?? null;
19 1
        $prefix = $options['prefix'] ?? null;
20
21 1
        $client = new S3Client([
22 1
            'version'     => $version,
23 1
            'region'      => $region,
24
            'credentials' => [
25 1
                'key'    => $key,
26 1
                'secret' => $secret
27
            ]
28
        ]);
29
30 1
        return new AwsS3Adapter($client, $bucket, $prefix);
31
    }
32
}
33