Passed
Push — develop ( f3d119...d95d5b )
by Paul
02:17
created

AttributeVisibilityHelper::getPropertyVisibility()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParserUtil;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\PropertyInterface\VisibilityInterface;
7
8
/**
9
 * Class AttributeVisibilityHelper.
10
 *
11
 * @author     Paul Thébaud <[email protected]>.
12
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
13
 * @license    https://opensource.org/licenses/MIT The MIT license.
14
 * @link       https://github.com/paul-thebaud/phpunit-generator
15
 * @since      Class available since Release 2.0.0.
16
 */
17
class AttributeVisibilityHelper
18
{
19
    /**
20
     * Get the visibility of a property.
21
     *
22
     * @param Node\Stmt\Property $property The property.
23
     *
24
     * @return int The visibility property.
25
     *
26
     * @see VisibilityInterface For different constants of visibility.
27
     */
28
    public static function getPropertyVisibility(Node\Stmt\Property $property): int
29
    {
30
        if ($property->isPrivate()) {
31
            return VisibilityInterface::PRIVATE;
32
        }
33
        if ($property->isProtected()) {
34
            return VisibilityInterface::PROTECTED;
35
        }
36
        return VisibilityInterface::PUBLIC;
37
    }
38
}
39