AttributeVisibilityHelper   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getVisibility() 0 9 3
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\Parser\NodeParserUtil;
13
14
use PhpParser\Node;
15
use PhpUnitGen\Model\PropertyInterface\VisibilityInterface;
16
17
/**
18
 * Class AttributeVisibilityHelper.
19
 *
20
 * @author     Paul Thébaud <[email protected]>.
21
 * @copyright  2017-2018 Paul Thébaud <[email protected]>.
22
 * @license    https://opensource.org/licenses/MIT The MIT license.
23
 * @link       https://github.com/paul-thebaud/phpunit-generator
24
 * @since      Class available since Release 2.0.0.
25
 */
26
class AttributeVisibilityHelper
27
{
28
    /**
29
     * Get the visibility of a property.
30
     *
31
     * @param Node\Stmt\Property $property The property.
32
     *
33
     * @return int The visibility property.
34
     *
35
     * @see VisibilityInterface For different constants of visibility.
36
     */
37
    public static function getVisibility(Node\Stmt\Property $property): int
38
    {
39
        if ($property->isPrivate()) {
40
            return VisibilityInterface::PRIVATE;
41
        }
42
        if ($property->isProtected()) {
43
            return VisibilityInterface::PROTECTED;
44
        }
45
        return VisibilityInterface::PUBLIC;
46
    }
47
}
48