Completed
Push — master ( a8a6e5...b4d61a )
by Arne
04:19
created

LocalStorageAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 4
1
<?php
2
3
namespace Archivr\StorageAdapter;
4
5
use Archivr\Exception\ConfigurationException;
6
use Archivr\PathUtils;
7
use Archivr\VaultConfiguration;
8
use League\Flysystem\Adapter\Local;
9
use League\Flysystem\Filesystem;
10
11
class LocalStorageAdapter extends FlysystemStorageAdapter
12
{
13
    public function __construct(VaultConfiguration $vaultConfiguration)
14
    {
15
        if (!($path = $vaultConfiguration->getSetting('path')))
16
        {
17
            throw new ConfigurationException("Missing vault config setting 'path' for vault '{$vaultConfiguration->getTitle()}'.'");
18
        }
19
20
        $path = PathUtils::getAbsolutePath($path);
21
22
        if (!is_dir($path) || !is_writable($path))
23
        {
24
            throw new ConfigurationException(sprintf('Path "%s" does not exist or is not writable.', $path));
25
        }
26
27
        $adapter = new Local($path);
28
        $filesystem = new Filesystem($adapter);
29
30
        parent::__construct($filesystem);
31
    }
32
}
33