FrontendError   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toString() 0 9 3
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: famoser
5
 * Date: 13/11/2016
6
 * Time: 12:29
7
 */
8
9
namespace Famoser\XKCDCache\Types;
10
11
12
/**
13
 * used to distinguish frontend errors
14
 *
15
 * @package Famoser\XKCDCache\Types
16
 */
17
class FrontendError
18
{
19
    const NOT_LOGGED_IN = 0;
20
    const ACCESS_DENIED = 1;
21
22
    /**
23
     * convert to string
24
     *
25
     * @param string $code
26
     * @return string
27
     */
28 2
    public static function toString($code)
29
    {
30
        switch ($code) {
31 2
            case self::NOT_LOGGED_IN:
32 1
                return 'not logged in';
33 2
            case self::ACCESS_DENIED:
34 2
                return 'you are not allowed to view this resource';
35
            default:
36 1
                return 'unknown error occurred with code ' . $code;
37
        }
38
    }
39
}