Passed
Push — develop ( fb709e...b69568 )
by Paul
03:14
created

MethodVisibilityTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMethodVisibility() 0 9 3
1
<?php
2
3
namespace PhpUnitGen\Parser\NodeParserUtil;
4
5
use PhpParser\Node;
6
use PhpUnitGen\Model\PropertyInterface\VisibilityInterface;
7
8
/**
9
 * Trait MethodVisibilityTrait.
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
trait MethodVisibilityTrait
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 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