Completed
Push — master ( 7f0cbd...5ec4be )
by Paweł
22s queued 15s
created

S3ClientFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 16
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A createS3Client() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Content Bundle.
7
 *
8
 * Copyright 2019 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2019 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\ContentBundle\Factory;
18
19
use Aws\S3\S3Client;
20
use Aws\Credentials\Credentials;
21
22
class S3ClientFactory
23
{
24
    public static function createS3Client(string $version, string $region, ?string $endpoint, string $key, string $secret): S3Client
25
    {
26
        $options = [
27
            'region' => $region,
28
            'version' => $version,
29
            'endpoint' => !empty($endpoint) ? $endpoint : null,
30
            'credentials' => new Credentials($key, $secret),
31
        ];
32
33
        $s3Client = new S3Client($options);
34
35
        return $s3Client;
36
    }
37
}
38