CodeParserConfiguration::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
nc 1
nop 1
dl 0
loc 12
ccs 11
cts 11
cp 1
crap 1
rs 9.9332
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Parser;
7
8
use Webmozart\Assert\Assert;
0 ignored issues
show
Bug introduced by
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
final class CodeParserConfiguration
11
{
12
    /** @var string */
13
    private const ASSOCIATIONS = 'associations';
14
15
    /** @var string */
16
    private const HIDE_PRIVATE = 'hide-private';
17
18
    /** @var string */
19
    private const HIDE_PROTECTED = 'hide-protected';
20
21
    /** @var string */
22
    private const HIDE_PROPERTIES = 'hide-attributes';
23
24
    /** @var string */
25
    private const HIDE_METHODS = 'hide-methods';
26
27
    private readonly bool $extractAssociations;
28
29
    private readonly bool $hideProtected;
30
31
    private readonly bool $hidePrivate;
32
33
    private readonly bool $hideAttributes;
34
35
    private readonly bool $hideMethods;
36
37 5
    public static function defaultConfiguration(): CodeParserConfiguration
38
    {
39 5
        return new CodeParserConfiguration([
40
            self::ASSOCIATIONS => false,
41
            self::HIDE_PRIVATE => false,
42
            self::HIDE_PROTECTED => false,
43
            self::HIDE_PROPERTIES => false,
44
            self::HIDE_METHODS => false,
45
        ]);
46
    }
47
48
    /** @param mixed[] $options */
49 43
    public function __construct(array $options)
50
    {
51 43
        Assert::boolean($options[self::ASSOCIATIONS], 'Extract associations option must be a boolean value');
52 42
        $this->extractAssociations = $options[self::ASSOCIATIONS];
0 ignored issues
show
Bug introduced by
The property extractAssociations is declared read-only in PhUml\Parser\CodeParserConfiguration.
Loading history...
53 42
        Assert::boolean($options[self::HIDE_PRIVATE], 'Hide private members option must be a boolean value');
54 41
        $this->hidePrivate = $options[self::HIDE_PRIVATE];
0 ignored issues
show
Bug introduced by
The property hidePrivate is declared read-only in PhUml\Parser\CodeParserConfiguration.
Loading history...
55 41
        Assert::boolean($options[self::HIDE_PROTECTED], 'Hide protected members option must be a boolean value');
56 40
        $this->hideProtected = $options[self::HIDE_PROTECTED];
0 ignored issues
show
Bug introduced by
The property hideProtected is declared read-only in PhUml\Parser\CodeParserConfiguration.
Loading history...
57 40
        Assert::boolean($options[self::HIDE_PROPERTIES], 'Hide attributes option must be a boolean value');
58 39
        $this->hideAttributes = $options[self::HIDE_PROPERTIES];
0 ignored issues
show
Bug introduced by
The property hideAttributes is declared read-only in PhUml\Parser\CodeParserConfiguration.
Loading history...
59 39
        Assert::boolean($options[self::HIDE_METHODS], 'Hide methods option must be a boolean value');
60 38
        $this->hideMethods = $options[self::HIDE_METHODS];
0 ignored issues
show
Bug introduced by
The property hideMethods is declared read-only in PhUml\Parser\CodeParserConfiguration.
Loading history...
61
    }
62
63 31
    public function extractAssociations(): bool
64
    {
65 31
        return $this->extractAssociations;
66
    }
67
68 38
    public function hidePrivate(): bool
69
    {
70 38
        return $this->hidePrivate;
71
    }
72
73 38
    public function hideProtected(): bool
74
    {
75 38
        return $this->hideProtected;
76
    }
77
78 38
    public function hideAttributes(): bool
79
    {
80 38
        return $this->hideAttributes;
81
    }
82
83 38
    public function hideMethods(): bool
84
    {
85 38
        return $this->hideMethods;
86
    }
87
}
88