Visibility::isValid()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

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