DownloadStatus   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 16
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toString() 0 14 5
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: famoser
5
 * Date: 27.05.2016
6
 * Time: 13:23
7
 */
8
9
namespace Famoser\XKCDCache\Types;
10
11
/**
12
 * any error which occurs by processing an api request
13
 *
14
 * @package Famoser\XKCDCache\Types
15
 */
16
class DownloadStatus
17
{
18
    const SUCCESSFUL = 0;
19
    const JSON_DOWNLOAD_FAILED = 1;
20
    const IMAGE_DOWNLOAD_FAILED = 2;
21
22
    const UNKNOWN_ERROR = 1000;
23
24
    /**
25
     * convert the api to a string
26
     *
27
     * @param $apiError
28
     * @return string
29
     */
30 3
    public static function toString($apiError)
31
    {
32
        switch ($apiError) {
33 3
            case self::SUCCESSFUL:
34 3
                return 'no error occurred';
35 1
            case self::JSON_DOWNLOAD_FAILED:
36 1
                return 'json download failed';
37 1
            case self::IMAGE_DOWNLOAD_FAILED:
38 1
                return 'image download failed';
39 1
            case self::UNKNOWN_ERROR:
40 1
                return 'an unknown error occurred';
41
42
            default:
43 1
                return 'unknown api error occurred with code ' . $apiError;
44
        }
45
    }
46
}
47