AwsS3AdapterFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A createAdapter() 0 10 3
1
<?php
2
3
namespace Lamoda\Codeception\Extension\AdapterFactory;
4
5
use Codeception\Exception\ModuleConfigException;
6
use League\Flysystem\AdapterInterface;
7
use Aws\S3\S3Client;
8
use League\Flysystem\AwsS3v3\AwsS3Adapter;
9
10
class AwsS3AdapterFactory implements AdapterFactoryInterface
11
{
12
    /**
13
     * @param array $config
14
     *
15
     * @return AdapterInterface
16
     */
17 3
    public static function createAdapter(array $config)
18
    {
19 3
        if(!isset($config['bucket']) or !is_string($config['bucket'])) {
20 2
            $message = sprintf('Configuration for s3 is broken. Configuration must contains bucket parameter with string type.');
21 2
            throw new ModuleConfigException(__CLASS__, $message);
22
        }
23
24 1
        $client = new S3Client($config);
25
26 1
        return new AwsS3Adapter($client, $config['bucket']);
27
    }
28
}
29