FtpdAdapterFactory::doCreateService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
 *
15
 * @package   bushbaby/flysystem
16
 */
17
18
declare(strict_types=1);
19
20
namespace BsbFlysystem\Adapter\Factory;
21
22
use BsbFlysystem\Exception\UnexpectedValueException;
23
use League\Flysystem\Adapter\Ftpd as Adapter;
24
use League\Flysystem\AdapterInterface;
25
use Psr\Container\ContainerInterface;
26
27 View Code Duplication
class FtpdAdapterFactory extends AbstractAdapterFactory
28
{
29
    public function doCreateService(ContainerInterface $container): AdapterInterface
30
    {
31
        return new Adapter($this->options);
32
    }
33
34
    protected function validateConfig(): void
35
    {
36
        if (! isset($this->options['host'])) {
37
            throw new UnexpectedValueException("Missing 'host' as option");
38
        }
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