Passed
Push — master ( 751d74...a1591c )
by Radu
01:11
created

Codes   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 10
eloc 35
c 1
b 0
f 0
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B getMessage() 0 27 10
1
<?php
2
namespace WebServCo\Framework\Files\Upload;
3
4
final class Codes
5
{
6
    const OK = 0;
7
    const INI_SIZE = 1;
8
    const FORM_SIZE = 2;
9
    const PARTIAL = 3;
10
    const NO_FILE = 4;
11
    const NO_TMP_DIR = 6;
12
    const CANT_WRITE = 7;
13
    const EXTENSION = 8;
14
    /* custom codes */
15
    const TYPE_NOT_ALLOWED = 91;
16
17
    public static function getMessage($errorCode)
18
    {
19
        switch ($errorCode) {
20
            case self::OK:
21
                return null;
22
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
23
            case self::INI_SIZE:
24
            case self::FORM_SIZE:
25
                return __('Uploaded file size exceeds maximum file size allowed');
26
                break;
27
            case self::PARTIAL:
28
                return __('The uploaded file was only partially uploaded');
29
                break;
30
            case self::NO_FILE:
31
                return __('No file was uploaded');
32
                break;
33
            case self::TYPE_NOT_ALLOWED:
34
                return __('File type not allowed');
35
                break;
36
            case self::CANT_WRITE:
37
                return __('Error saving uploaded file');
38
                break;
39
            case self::NO_TMP_DIR:
40
            case self::EXTENSION:
41
            default:
42
                return __('Upload error');
43
                break;
44
        }
45
    }
46
}
47