Completed
Push — master ( 389baa...c7c5a4 )
by Luis
14:17 queued 08:06
created

Visibility::protected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * PHP version 7.1
4
 *
5
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
6
 */
7
8
namespace PhUml\Code\Modifiers;
9
10
/**
11
 * It represents the visibility of either an attribute or a method
12
 */
13
class Visibility
14
{
15
    /** @var string[] */
16
    private static $symbols = [
17
        'private' => '-',
18
        'public' => '+',
19
        'protected' => '#',
20
    ];
21
22
    /** @var string */
23
    private $modifier;
24
25 174
    private function __construct(string $modifier)
26
    {
27 174
        $this->modifier = $modifier;
28 174
    }
29
30 150
    public static function public(): Visibility
31
    {
32 150
        return new Visibility('public');
33
    }
34
35 78
    public static function protected(): Visibility
36
    {
37 78
        return new Visibility('protected');
38
    }
39
40 90
    public static function private(): Visibility
41
    {
42 90
        return new Visibility('private');
43
    }
44
45 30
    public function equals(Visibility $another): bool
46
    {
47 30
        return $this->modifier === $another->modifier;
48
    }
49
50 69
    public function __toString()
51
    {
52 69
        return sprintf('%s', self::$symbols[$this->modifier]);
53
    }
54
}
55