Passed
Push — master ( 2b0e69...0701c6 )
by Luis
39s queued 11s
created

src/Code/Modifiers/Visibility.php (1 issue)

Labels
Severity
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
use Webmozart\Assert\Assert;
0 ignored issues
show
The type Webmozart\Assert\Assert was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 * It represents the visibility of either an attribute or a method
14
 */
15
class Visibility
16
{
17
    /** @var string[] */
18
    private static $symbols = [
19
        'private' => '-',
20
        'public' => '+',
21
        'protected' => '#',
22
    ];
23
24
    /** @var string */
25 234
    private $modifier;
26
27 234
    public function __construct(string $modifier)
28 234
    {
29
        Assert::oneOf($modifier, array_keys(self::$symbols));
30 201
        $this->modifier = $modifier;
31
    }
32 201
33
    public static function public(): Visibility
34
    {
35 99
        return new Visibility('public');
36
    }
37 99
38
    public static function protected(): Visibility
39
    {
40 120
        return new Visibility('protected');
41
    }
42 120
43
    public static function private(): Visibility
44
    {
45 57
        return new Visibility('private');
46
    }
47 57
48
    public function equals(Visibility $another): bool
49
    {
50 72
        return $this->modifier === $another->modifier;
51
    }
52 72
53
    public function __toString()
54
    {
55
        return sprintf('%s', self::$symbols[$this->modifier]);
56
    }
57
}
58