Passed
Pull Request — master (#42)
by
unknown
08:12 queued 05:35
created

AbstractAwsS3V3Factory::getFilesystemAdapter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 15
rs 9.9332
1
<?php
2
3
namespace AnyCloud\Service\File\Store;
4
5
use Aws\S3\S3Client;
6
use League\Flysystem\AwsS3V3\AwsS3V3Adapter;
7
use League\Flysystem\FilesystemAdapter;
8
9
abstract class AbstractAwsS3V3Factory extends AbstractFlysystemFactory
10
{
11
    protected function getFilesystemAdapter(array $config): FilesystemAdapter
12
    {
13
        $options = [
14
            'credentials' => [
15
                'key'    => $config['key'],
16
                'secret' => $config['secret'],
17
            ],
18
            'region'   => $config['region'],
19
            'endpoint' => $config['endpoint'],
20
            'version'  => 'latest',
21
        ];
22
        $client = new S3Client($options);
23
        $adapter = new AwsS3V3Adapter($client, $config['bucket']);
24
25
        return $adapter;
26
    }
27
}
28