VisibilityMethod   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 4
c 3
b 0
f 1
lcom 1
cbo 2
dl 0
loc 47
ccs 20
cts 20
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getVisibility() 0 4 1
A setVisibility() 0 7 1
A toString() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the ClassGeneration package.
5
 *
6
 * (c) Antonio Spinelli <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ClassGeneration\Composition;
13
14
use ClassGeneration\Visibility;
15
16
/**
17
 * Composition Trait Visibility Method ClassGeneration
18
 * @author Antonio Spinelli <[email protected]>
19
 */
20
class VisibilityMethod extends Method implements VisibilityMethodInterface
21
{
22
23
    protected $visibility;
24
25 8
    public function __construct($traitName, $name, $visibility)
26
    {
27 8
        $this->setTraitName($traitName);
28 8
        $this->setName($name);
29 8
        $this->setVisibility($visibility);
30 8
        $this->init();
31 8
    }
32
33
    /**
34
     * @inheritdoc
35
     */
36 5
    public function getVisibility()
37
    {
38 5
        return $this->visibility;
39
    }
40
41
    /**
42
     * @inheritdoc
43
     * @return VisibilityMethod
44
     */
45 8
    public function setVisibility($visibility)
46
    {
47 8
        Visibility::isValid($visibility);
48 8
        $this->visibility = $visibility;
49
50 8
        return $this;
51
    }
52
53
    /**
54
     * @inheritdoc
55
     */
56 4
    public function toString()
57
    {
58 4
        $result = sprintf(
59 4
            '%s::%s as %s;',
60 4
            $this->getTraitName(),
61 4
            $this->getName(),
62 4
            $this->getVisibility()
63 4
        );
64 4
        return $result . PHP_EOL;
65
    }
66
}
67