Visibility   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 3 Features 0
Metric Value
wmc 4
c 5
b 3
f 0
lcom 0
cbo 0
dl 0
loc 28
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 10 4
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;
13
14
/**
15
 * @author Antonio Spinelli <[email protected]>
16
 */
17
class Visibility
18
{
19
20
    const TYPE_PUBLIC = 'public';
21
22
    const TYPE_PRIVATE = 'private';
23
24
    const TYPE_PROTECTED = 'protected';
25
26
    /**
27
     * Validate visiblity.
28
     *
29
     * @param string $visibility
30
     *
31
     * @throws \InvalidArgumentException
32
     * @return bool
33
     */
34 62
    public static function isValid($visibility)
35
    {
36
        switch ($visibility) {
37 62
            case Visibility::TYPE_PRIVATE:
38 62
            case Visibility::TYPE_PROTECTED:
39 62
            case Visibility::TYPE_PUBLIC:
40 62
                return true;
41
        }
42 1
        throw new \InvalidArgumentException('The ' . $visibility . ' is not allowed');
43
    }
44
}
45