S3AdapterFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 23
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 20 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