Passed
Pull Request — master (#407)
by Kirill
05:29
created

AbstractBuilder::__construct()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
/**
4
 * This file is part of Spiral Framework package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Storage\Builder\Adapter;
13
14
use Spiral\Storage\Config\DTO\FileSystemInfo\FileSystemInfoInterface;
15
use Spiral\Storage\Exception\StorageException;
16
17
abstract class AbstractBuilder implements AdapterBuilderInterface
18
{
19
    /**
20
     * Filesystem info class required for builder
21
     */
22
    protected const FILE_SYSTEM_INFO_CLASS = '';
23
24
    /**
25
     * @var FileSystemInfoInterface
26
     */
27
    protected $fsInfo;
28
29
    /**
30
     * @param FileSystemInfoInterface $fsInfo
31
     *
32
     * @throws StorageException
33
     */
34
    public function __construct(FileSystemInfoInterface $fsInfo)
35
    {
36
        $requiredClass = static::FILE_SYSTEM_INFO_CLASS;
37
38
        if (empty($requiredClass) || !$fsInfo instanceof $requiredClass) {
0 ignored issues
show
introduced by
The condition empty($requiredClass) is always true.
Loading history...
39
            throw new StorageException(
40
                \sprintf('Wrong filesystem info `%s` provided for `%s`', get_class($fsInfo), static::class)
41
            );
42
        }
43
44
        $this->fsInfo = $fsInfo;
45
    }
46
}
47