AbstractAwsS3V3Factory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getFilesystemAdapter() 0 15 1
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'] ?? $config['secret_key'],
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