Completed
Pull Request — master (#42)
by Florent
12:58
created

FtpAdapterFactory::validateConfig()   A

Complexity

Conditions 5
Paths 5

Size

Total Lines 18

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 5

Importance

Changes 0
Metric Value
dl 18
loc 18
ccs 10
cts 10
cp 1
rs 9.3554
c 0
b 0
f 0
cc 5
nc 5
nop 0
crap 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BsbFlysystem\Adapter\Factory;
6
7
use BsbFlysystem\Exception\UnexpectedValueException;
8
use League\Flysystem\Adapter\Ftp as Adapter;
9
use League\Flysystem\AdapterInterface;
10
use Psr\Container\ContainerInterface;
11
12
class FtpAdapterFactory extends AbstractAdapterFactory
13
{
14
    public function doCreateService(ContainerInterface $container): AdapterInterface
15
    {
16
        $adapter = new Adapter($this->options);
17
18
        return $adapter;
19
    }
20
21 5 View Code Duplication
    protected function validateConfig()
22
    {
23 5
        if (! isset($this->options['host'])) {
24 1
            throw new UnexpectedValueException("Missing 'host' as option");
25
        }
26
27 4
        if (! isset($this->options['port'])) {
28 1
            throw new UnexpectedValueException("Missing 'port' as option");
29
        }
30
31 3
        if (! isset($this->options['username'])) {
32 1
            throw new UnexpectedValueException("Missing 'username' as option");
33
        }
34
35 2
        if (! isset($this->options['password'])) {
36 1
            throw new UnexpectedValueException("Missing 'password' as option");
37
        }
38 1
    }
39
}
40