Passed
Push — master ( 59589b...c79df9 )
by Enjoys
05:41 queued 03:11
created

AssetOption::isReplaceRelativeUrls()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Enjoys\AssetsCollector;
4
5
final class AssetOption
6
{
7
8
    public const MINIFY = 'minify';
9
    public const REPLACE_RELATIVE_URLS = 'replaceRelativeUrls';
10
    public const SYMLINKS = 'symlinks';
11
    public const NOT_COLLECT = 'notCollect';
12
    public const ATTRIBUTES = 'attributes';
13
14
    private bool $minify = true;
15
    private bool $replaceRelativeUrls = true;
16
    private bool $notCollect = false;
17
    private ?array $attributes = null;
18
    /**
19
     * @var array<string, string>
20
     */
21
    private array $symlinks = [];
22
23
    /**
24
     * @param array<string, string|bool|array|null> $options
25
     */
26 54
    public function __construct(array $options = [])
27
    {
28 54
        $this->setOptions($options);
29
    }
30
31
    /**
32
     * @param array<string, string|bool|array|null> $options
33
     * @return $this
34
     */
35 54
    public function setOptions(array $options = []): AssetOption
36
    {
37 54
        foreach ($options as $key => $value) {
38 11
            if (!property_exists($this, $key)) {
39
                continue;
40
            }
41 11
            $this->setOption($key, $value);
42
        }
43 54
        return $this;
44
    }
45
46
    /**
47
     * @param string $key
48
     * @param string|bool|array|null $value
49
     * @return $this
50
     */
51 24
    public function setOption(string $key, $value): AssetOption
52
    {
53 24
        $this->$key = $value;
54 24
        return $this;
55
    }
56
57 16
    public function isMinify(): bool
58
    {
59 16
        return $this->minify;
60
    }
61
62 9
    public function isReplaceRelativeUrls(): bool
63
    {
64 9
        return $this->replaceRelativeUrls;
65
    }
66
67 4
    public function isNotCollect(): bool
68
    {
69 4
        return $this->notCollect;
70
    }
71
72 14
    public function getAttributes(): ?array
73
    {
74 14
        return $this->attributes;
75
    }
76
77
    /**
78
     * @return array<string, string>
79
     */
80 16
    public function getSymlinks(): array
81
    {
82 16
        return $this->symlinks;
83
    }
84
}
85