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

FtpAdapterFactory::doCreateService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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