SftpFactory::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 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 League\Flysystem\AdapterInterface;
20
use League\Flysystem\Sftp\SftpAdapter;
21
22
/**
23
 * SftpFactory
24
 */
25
class SftpFactory extends AbstractFactory
26
{
27
    protected string $alias = 'sftp';
28
    protected ?string $package = 'league/flysystem-sftp';
29
    protected string $className = SftpAdapter::class;
30
    protected array $defaults = [
31
        'host' => '',
32
        'port' => 22,
33
        'username' => '',
34
        'password' => '',
35
        'privateKey' => '',
36
        'passphrase' => '',
37
        'root' => '/',
38
        'timeout' => 10,
39
        'directoryPerm' => 0755
40
    ];
41
42
    /**
43
     * @inheritDoc
44
     */
45 1
    public function build(array $config): AdapterInterface
46
    {
47 1
        $config += $this->defaults;
48
49 1
        return new SftpAdapter($config);
50
    }
51
}
52