VisibilityTrait::isPublic()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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