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

LocalAdapterFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 16
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A validateConfig() 0 6 2
A doCreateService() 0 6 1
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\Local as Adapter;
9
use League\Flysystem\AdapterInterface;
10
use Psr\Container\ContainerInterface;
11
12
class LocalAdapterFactory extends AbstractAdapterFactory
13
{
14
    public function doCreateService(ContainerInterface $container): AdapterInterface
15
    {
16
        $adapter = new Adapter($this->options['root']);
17
18
        return $adapter;
19
    }
20
21 2
    protected function validateConfig()
22
    {
23 2
        if (! isset($this->options['root'])) {
24 1
            throw new UnexpectedValueException("Missing 'root' as option");
25
        }
26 1
    }
27
}
28