Completed
Push — develop ( 74dbd7...d5cb43 )
by Paul
02:08
created

VisibilityTrait::setVisibility()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
3
namespace PhpUnitGen\Model\PropertyTrait;
4
5
use PhpUnitGen\Model\PropertyInterface\VisibilityInterface;
6
7
/**
8
 * Trait VisibilityTrait.
9
 *
10
 * @author     Paul Thébaud <[email protected]>.
11
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
12
 * @license    https://opensource.org/licenses/MIT The MIT license.
13
 * @link       https://github.com/paul-thebaud/phpunit-generator
14
 * @since      Class available since Release 2.0.0.
15
 */
16
trait VisibilityTrait
17
{
18
    /**
19
     * @var int|null $visibility The visibility as an integer constant.
20
     */
21
    protected $visibility = VisibilityInterface::UNKNOWN_VISIBILITY;
22
23
    /**
24
     * @param int|null $visibility The new visibility to set.
25
     */
26
    public function setVisibility(?int $visibility): void
27
    {
28
        $this->visibility = $visibility;
29
    }
30
31
    /**
32
     * @return int|null The current visibility.
33
     */
34
    public function getVisibility(): ?int
35
    {
36
        return $this->visibility;
37
    }
38
39
    /**
40
     * @return bool True if the function is not protected or private.
41
     */
42
    public function isPublic(): bool
43
    {
44
        return $this->visibility !== VisibilityInterface::PRIVATE
45
            && $this->visibility !== VisibilityInterface::PROTECTED;
46
    }
47
}
48