Completed
Push — develop ( 7858d8...735899 )
by Jaap
05:56
created

Settings::setMarkers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * This file is part of phpDocumentor.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @author    Mike van Riel <[email protected]>
11
 * @copyright 2010-2018 Mike van Riel / Naenius (http://www.naenius.com)
12
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
13
 * @link      http://phpdoc.org
14
 */
15
16
namespace phpDocumentor\Descriptor\ProjectDescriptor;
17
18
/**
19
 * Contains the Settings for the current Project.
20
 */
21
class Settings
22
{
23
    const VISIBILITY_PUBLIC = 1;
24
25
    const VISIBILITY_PROTECTED = 2;
26
27
    const VISIBILITY_PRIVATE = 4;
28
29
    const VISIBILITY_INTERNAL = 8;
30
31
    /** @var integer by default ignore internal visibility but show others */
32
    const VISIBILITY_DEFAULT = 7;
33
34
    /** @var boolean Represents whether this settings object has been modified */
35
    protected $isModified = false;
36
37
    /** @var integer a bitflag representing which visibilities are contained and allowed in this project */
38
    protected $visibility = self::VISIBILITY_DEFAULT;
39
40
    /** @var bool */
41
    protected $includeSource = false;
42
43
    private $markers;
44
45
    /**
46
     * Stores the visibilities that are allowed to be executed as a bitflag.
47
     *
48
     * @param integer $visibilityFlag A bitflag combining the VISIBILITY_* constants.
49
     */
50
    public function setVisibility($visibilityFlag)
51
    {
52
        $this->setValueAndCheckIfModified('visibility', $visibilityFlag);
53
    }
54
55
    /**
56
     * Returns the bit flag representing which visibilities are allowed.
57
     *
58
     * @see self::isVisibilityAllowed() for a convenience method to easily check against a specific visibility.
59
     *
60
     * @return integer
61
     */
62
    public function getVisibility()
63
    {
64
        return $this->visibility;
65
    }
66
67
    /**
68
     * Returns whether one of the values of this object was modified.
69
     *
70
     * @return boolean
71
     */
72
    public function isModified()
73
    {
74
        return $this->isModified;
75
    }
76
77
    /**
78
     * Resets the flag indicating whether the settings have changed.
79
     */
80
    public function clearModifiedFlag()
81
    {
82
        $this->isModified = false;
83
    }
84
85
    /**
86
     * Sets a property's value and if it differs from the previous then mark these settings as modified.
87
     */
88
    protected function setValueAndCheckIfModified($propertyName, $value)
89
    {
90
        if ($this->{$propertyName} !== $value) {
91
            $this->isModified = true;
92
        }
93
94
        $this->{$propertyName} = $value;
95
    }
96
97
    public function includeSource()
98
    {
99
        $this->includeSource = true;
100
    }
101
102
    public function excludeSource()
103
    {
104
        $this->includeSource = false;
105
    }
106
107
    public function shouldIncludeSource()
108
    {
109
        return $this->includeSource;
110
    }
111
112 1
    public function setMarkers(array $markers)
113
    {
114 1
        $this->markers = $markers;
115 1
    }
116
117 1
    public function getMarkers()
118
    {
119 1
        return $this->markers;
120
    }
121
}
122