FtpAdapterFactory::validateConfig()   A
last analyzed

Complexity

Conditions 5
Paths 5

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 5

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 3
cts 3
cp 1
rs 9.3554
c 0
b 0
f 0
cc 5
nc 5
nop 0
crap 5
1
<?php
2
3
/**
4
 * BsbFlystem
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @see       https://bushbaby.nl/
10
 *
11
 * @copyright Copyright (c) 2014-2021 bushbaby multimedia. (https://bushbaby.nl)
12
 * @author    Bas Kamer <[email protected]>
13
 * @license   MIT
14 1
 *
15
 * @package   bushbaby/flysystem
16 1
 */
17
18 1
declare(strict_types=1);
19
20
namespace BsbFlysystem\Adapter\Factory;
21 6
22
use BsbFlysystem\Exception\UnexpectedValueException;
23 6
use League\Flysystem\Adapter\Ftp as Adapter;
24 1
use League\Flysystem\AdapterInterface;
25
use Psr\Container\ContainerInterface;
26
27 5 View Code Duplication
class FtpAdapterFactory extends AbstractAdapterFactory
28 1
{
29
    public function doCreateService(ContainerInterface $container): AdapterInterface
30
    {
31 4
        return new Adapter($this->options);
32 1
    }
33
34
    protected function validateConfig(): void
35 3
    {
36 1
        if (! isset($this->options['host'])) {
37
            throw new UnexpectedValueException("Missing 'host' as option");
38 2
        }
39
40
        if (! isset($this->options['port'])) {
41
            throw new UnexpectedValueException("Missing 'port' as option");
42
        }
43
44
        if (! isset($this->options['username'])) {
45
            throw new UnexpectedValueException("Missing 'username' as option");
46
        }
47
48
        if (! isset($this->options['password'])) {
49
            throw new UnexpectedValueException("Missing 'password' as option");
50
        }
51
    }
52
}
53