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

LocalInfo   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 41
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A isAdvancedUsage() 0 13 4
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\Config\DTO\FileSystemInfo;
13
14
use Spiral\Storage\Resolver\LocalSystemResolver;
15
16
class LocalInfo extends FileSystemInfo
17
{
18
    public const ROOT_DIR_KEY = 'directory';
19
    public const WRITE_FLAGS_KEY = 'write-flags';
20
    public const LINK_HANDLING_KEY = 'link-handling';
21
    public const HOST_KEY = 'host';
22
23
    protected const FILE_SYSTEM_INFO_TYPE = 'local';
24
25
    protected const REQUIRED_OPTIONS = [
26
        self::ROOT_DIR_KEY => self::STRING_TYPE,
27
    ];
28
29
    protected const ADDITIONAL_OPTIONS = [
30
        self::VISIBILITY_KEY => self::ARRAY_TYPE,
31
        self::WRITE_FLAGS_KEY => self::INT_TYPE,
32
        self::LINK_HANDLING_KEY => self::INT_TYPE,
33
        self::HOST_KEY => self::STRING_TYPE,
34
    ];
35
36
    /**
37
     * @var class-string
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string.
Loading history...
38
     */
39
    protected $resolver = LocalSystemResolver::class;
40
41
    /**
42
     * @inheritDoc
43
     */
44
    public function isAdvancedUsage(): bool
45
    {
46
        foreach (static::ADDITIONAL_OPTIONS as $optionalOption => $type) {
47
            if ($optionalOption === static::HOST_KEY) {
48
                continue;
49
            }
50
51
            if ($this->hasOption($optionalOption)) {
52
                return true;
53
            }
54
        }
55
56
        return false;
57
    }
58
}
59