AwsFilesystemFacadeDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
c 2
b 0
f 0
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createFsOperator() 0 7 2
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Filesystem\Adapter\Aws\Decorator;
15
16
use League\Flysystem\FilesystemOperator;
17
use Micro\Plugin\Filesystem\Adapter\Aws\Configuration\FilesystemS3AdapterPluginConfigurationInterface;
18
use Micro\Plugin\Filesystem\Business\FS\FsFactoryInterface;
19
use Micro\Plugin\Filesystem\Configuration\FilesystemPluginConfigurationInterface;
20
use Micro\Plugin\Filesystem\Facade\FilesystemFacadeInterface;
21
22
class AwsFilesystemFacadeDecorator implements FilesystemFacadeInterface
23
{
24
    /**
25
     * @param FilesystemFacadeInterface              $filesystemFacade
26
     * @param FsFactoryInterface                     $fsFactory
27
     * @param FilesystemPluginConfigurationInterface $adapterConfiguration
28
     */
29 2
    public function __construct(
30
        private readonly FilesystemFacadeInterface $filesystemFacade,
31
        private readonly FsFactoryInterface $fsFactory,
32
        private readonly FilesystemPluginConfigurationInterface $adapterConfiguration
33
    ) {
34 2
    }
35
36
    /**
37
     * {@inheritDoc}
38
     */
39 2
    public function createFsOperator(string $adapterName = FilesystemPluginConfigurationInterface::ADAPTER_DEFAULT): FilesystemOperator
40
    {
41 2
        if (FilesystemS3AdapterPluginConfigurationInterface::ADAPTER_NAME !== $this->adapterConfiguration->getAdapterType($adapterName)) {
42 1
            return $this->filesystemFacade->createFsOperator($adapterName);
43
        }
44
45 1
        return $this->fsFactory->create($adapterName);
46
    }
47
}
48