Passed
Pull Request — master (#407)
by Kirill
06:59
created

AwsS3Builder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildAdvanced() 0 11 2
A buildSimple() 0 7 1
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Storage\Builder\Adapter;
13
14
use League\Flysystem\FilesystemAdapter;
15
use Spiral\Storage\Config\DTO\FileSystemInfo\Aws\AwsS3Info;
16
use Spiral\Storage\Config\DTO\FileSystemInfo\FileSystemInfoInterface;
17
18
/**
19
 * @property FileSystemInfoInterface|AwsS3Info $fsInfo
20
 */
21
class AwsS3Builder extends AbstractBuilder
22
{
23
    protected const FILE_SYSTEM_INFO_CLASS = AwsS3Info::class;
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function buildSimple(): FilesystemAdapter
29
    {
30
        $adapterClass = $this->fsInfo->getAdapterClass();
31
32
        return new $adapterClass(
33
            $this->fsInfo->getClient(),
0 ignored issues
show
Bug introduced by
The method getClient() does not exist on Spiral\Storage\Config\DT...FileSystemInfoInterface. It seems like you code against a sub-type of Spiral\Storage\Config\DT...FileSystemInfoInterface such as Spiral\Storage\Config\DT...ystemInfo\Aws\AwsS3Info. ( Ignorable by Annotation )

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

33
            $this->fsInfo->/** @scrutinizer ignore-call */ 
34
                           getClient(),
Loading history...
34
            $this->fsInfo->getOption(AwsS3Info::BUCKET_KEY)
0 ignored issues
show
Bug introduced by
The method getOption() does not exist on Spiral\Storage\Config\DT...FileSystemInfoInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Spiral\Storage\Config\DT...FileSystemInfoInterface. ( Ignorable by Annotation )

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

34
            $this->fsInfo->/** @scrutinizer ignore-call */ 
35
                           getOption(AwsS3Info::BUCKET_KEY)
Loading history...
35
        );
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function buildAdvanced(): FilesystemAdapter
42
    {
43
        $adapterClass = $this->fsInfo->getAdapterClass();
44
45
        return new $adapterClass(
46
            $this->fsInfo->getClient(),
47
            $this->fsInfo->getOption(AwsS3Info::BUCKET_KEY),
48
            $this->fsInfo->hasOption(AwsS3Info::PATH_PREFIX_KEY)
0 ignored issues
show
Bug introduced by
The method hasOption() does not exist on Spiral\Storage\Config\DT...FileSystemInfoInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Spiral\Storage\Config\DT...FileSystemInfoInterface. ( Ignorable by Annotation )

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

48
            $this->fsInfo->/** @scrutinizer ignore-call */ 
49
                           hasOption(AwsS3Info::PATH_PREFIX_KEY)
Loading history...
49
                ? $this->fsInfo->getOption(AwsS3Info::PATH_PREFIX_KEY)
50
                : '',
51
            $this->fsInfo->getVisibilityConverter()
0 ignored issues
show
Bug introduced by
The method getVisibilityConverter() does not exist on Spiral\Storage\Config\DT...FileSystemInfoInterface. It seems like you code against a sub-type of Spiral\Storage\Config\DT...FileSystemInfoInterface such as Spiral\Storage\Config\DT...ystemInfo\Aws\AwsS3Info. ( Ignorable by Annotation )

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

51
            $this->fsInfo->/** @scrutinizer ignore-call */ 
52
                           getVisibilityConverter()
Loading history...
52
        );
53
    }
54
}
55