Failed Conditions
Pull Request — master (#1)
by Florian
04:43
created

AwsS3v3Factory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 17
dl 0
loc 28
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A build() 0 10 1
1
<?php
2
3
/**
4
 * Copyright (c) Florian Krämer (https://florian-kraemer.net)
5
 * Licensed under The MIT License
6
 * For full copyright and license information, please see the LICENSE.txt
7
 * Redistributions of files must retain the above copyright notice.
8
 *
9
 * @copyright Copyright (c) Florian Krämer (https://florian-kraemer.net)
10
 * @author    Florian Krämer
11
 * @link      https://github.com/Phauthentic
12
 * @license   https://opensource.org/licenses/MIT MIT License
13
 */
14
15
declare(strict_types=1);
16
17
namespace Phauthentic\Infrastructure\Storage\Factories;
18
19
use Aws\S3\S3Client;
20
use League\Flysystem\AdapterInterface;
21
use League\Flysystem\AwsS3v3\AwsS3Adapter;
22
23
/**
24
 * AwsS3Factory
25
 */
26
class AwsS3v3Factory extends AbstractFactory
27
{
28
    protected string $alias = 's3';
29
    protected ?string $package = 'league/flysystem-aws-s3-v3';
30
    protected string $className = AwsS3Adapter::class;
31
32
    protected array $defaults = [
33
        'bucket' => null,
34
        'prefix' => '',
35
        'client' => [
36
            'region' => 'eu',
37
            'version' => '2006-03-01'
38
        ]
39
    ];
40
41
    /**
42
     * @inheritDoc
43
     */
44 1
    public function build(array $config): AdapterInterface
45
    {
46 1
        $this->availabilityCheck();
47 1
        $config = array_merge($this->defaults, $config);
48
49 1
        return new AwsS3Adapter(S3Client::factory(
0 ignored issues
show
Deprecated Code introduced by
The function Aws\AwsClient::factory() has been deprecated. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

49
        return new AwsS3Adapter(/** @scrutinizer ignore-deprecated */ S3Client::factory(
Loading history...
50 1
            $config['client']),
51 1
            $config['bucket'],
52 1
            $config['prefix'],
53
            $config
54
        );
55
    }
56
}
57