VisibilityMethod::toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4286
cc 1
eloc 7
nc 1
nop 0
crap 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