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

MethodVisibilityHelper::getMethodVisibility()   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 MethodVisibilityHelper.
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 MethodVisibilityHelper
18
{
19
    /**
20
     * Get the visibility of a method.
21
     *
22
     * @param Node\Stmt\ClassMethod $method The method.
23
     *
24
     * @return int The visibility method.
25
     *
26
     * @see VisibilityInterface For different constants of visibility.
27
     */
28
    public static function getMethodVisibility(Node\Stmt\ClassMethod $method): int
29
    {
30
        if ($method->isPrivate()) {
31
            return VisibilityInterface::PRIVATE;
32
        }
33
        if ($method->isProtected()) {
34
            return VisibilityInterface::PROTECTED;
35
        }
36
        return VisibilityInterface::PUBLIC;
37
    }
38
}
39