Passed
Push — master ( d46d5f...674e23 )
by Luis
44s queued 12s
created

CodeParserConfiguration::hidePrivate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * PHP version 8.0
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Parser;
9
10
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...
11
12
final class CodeParserConfiguration
13
{
14
    /** @var string */
15
    private const ASSOCIATIONS = 'associations';
16
17
    /** @var string */
18
    private const HIDE_PRIVATE = 'hide-private';
19
20
    /** @var string */
21
    private const HIDE_PROTECTED = 'hide-protected';
22
23
    /** @var string */
24
    private const HIDE_ATTRIBUTES = 'hide-attributes';
25
26
    /** @var string */
27
    private const HIDE_METHODS = 'hide-methods';
28
29
    private bool $extractAssociations;
30
31
    private bool $hideProtected;
32
33
    private bool $hidePrivate;
34
35
    private bool $hideAttributes;
36
37
    private bool $hideMethods;
38
39
    public static function defaultConfiguration(): CodeParserConfiguration
40
    {
41
        return new CodeParserConfiguration([
42
            self::ASSOCIATIONS => false,
43
            self::HIDE_PRIVATE => false,
44
            self::HIDE_PROTECTED => false,
45
            self::HIDE_ATTRIBUTES => false,
46
            self::HIDE_METHODS => false,
47
        ]);
48
    }
49
50
    /** @param mixed[] $options */
51
    public function __construct(array $options)
52
    {
53
        Assert::boolean($options[self::ASSOCIATIONS], 'Extract associations option must be a boolean value');
54
        $this->extractAssociations = $options[self::ASSOCIATIONS];
55
        Assert::boolean($options[self::HIDE_PRIVATE], 'Hide private members option must be a boolean value');
56
        $this->hidePrivate = $options[self::HIDE_PRIVATE];
57
        Assert::boolean($options[self::HIDE_PROTECTED], 'Hide protected members option must be a boolean value');
58
        $this->hideProtected = $options[self::HIDE_PROTECTED];
59
        Assert::boolean($options[self::HIDE_ATTRIBUTES], 'Hide attributes option must be a boolean value');
60
        $this->hideAttributes = $options[self::HIDE_ATTRIBUTES];
61
        Assert::boolean($options[self::HIDE_METHODS], 'Hide methods option must be a boolean value');
62
        $this->hideMethods = $options[self::HIDE_METHODS];
63
    }
64
65
    public function extractAssociations(): bool
66
    {
67
        return $this->extractAssociations;
68
    }
69
70
    public function hidePrivate(): bool
71
    {
72
        return $this->hidePrivate;
73
    }
74
75
    public function hideProtected(): bool
76
    {
77
        return $this->hideProtected;
78
    }
79
80
    public function hideAttributes(): bool
81
    {
82
        return $this->hideAttributes;
83
    }
84
85
    public function hideMethods(): bool
86
    {
87
        return $this->hideMethods;
88
    }
89
}
90