Completed
Pull Request — master (#3)
by
unknown
16:26
created

S3AdapterFactory::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 0
cts 8
cp 0
rs 9.6666
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 Aws\S3\S3Client;
7
use League\Flysystem\AwsS3v3\AwsS3Adapter;
8
use WShafer\PSR11FlySystem\FactoryInterface;
9
10
class S3AdapterFactory implements FactoryInterface
11
{
12
    public function __invoke(array $options)
13
    {
14
        $options = array_merge([
15
            'key' => null,
16
            'secret' => null,
17
            'region' => 'us-east-1',
18
            'version' => 'latest',
19
            'bucket' => null,
20
            'prefix' => null,
21
        ], $options);
22
23
        $bucket = $options['bucket'];
24
        $prefix = $options['prefix'];
25
26
        $client = new S3Client($options);
27
28
        return new AwsS3Adapter($client, $bucket, $prefix);
29
    }
30
}
31