AssetOption::setOption()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 2
cts 3
cp 0.6667
crap 1.037
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
    /**
18
     * @var array<string, string>
19
     */
20
    private array $symlinks = [];
21
22
23
    /**
24
     * @param array<string, bool|array> $options
25
     */
26 54
    public function __construct(array $options = [])
27
    {
28 54
        foreach ($options as $key => $value) {
29
            if (!property_exists($this, $key)) {
30
                continue;
31
            }
32
            $this->setOption($key, $value);
33
        }
34
    }
35 54
36
    public function setOption(string $key, bool|array $value): AssetOption
37 54
    {
38 13
        $this->$key = $value;
39
        return $this;
40
    }
41 13
42
    public function isMinify(): bool
43 54
    {
44
        return $this->minify;
45
    }
46
47
    public function isReplaceRelativeUrls(): bool
48
    {
49
        return $this->replaceRelativeUrls;
50
    }
51 24
52
    public function isNotCollect(): bool
53 24
    {
54 24
        return $this->notCollect;
55
    }
56
57 12
    /**
58
     * @return array<string, string>
59 12
     */
60
    public function getSymlinks(): array
61
    {
62 12
        return $this->symlinks;
63
    }
64
}
65