ZipStatus::ZipStatusString()   D
last analyzed

Complexity

Conditions 25
Paths 25

Size

Total Lines 54
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 51
dl 0
loc 54
rs 4.1666
c 2
b 0
f 0
cc 25
nc 25
nop 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: macbookpro
5
 * Date: 04/05/18
6
 * Time: 08:22.
7
 */
8
9
namespace Ballybran\Helpers\Zip;
10
11
class ZipStatus
12
{
13
    public function ZipStatusString($errno)
14
    {
15
        switch ((int)$errno) {
16
            case \ZipArchive::ER_OK:
17
                return 'N No error';
18
            case \ZipArchive::ER_MULTIDISK:
19
                return 'N Multi-disk zip archives not supported';
20
            case \ZipArchive::ER_RENAME:
21
                return 'S Renaming temporary file failed';
22
            case \ZipArchive::ER_CLOSE:
23
                return 'S Closing zip archive failed';
24
            case \ZipArchive::ER_SEEK:
25
                return 'S Seek error';
26
            case \ZipArchive::ER_READ:
27
                return 'S Read error';
28
            case \ZipArchive::ER_WRITE:
29
                return 'S Write error';
30
            case \ZipArchive::ER_CRC:
31
                return 'N CRC error';
32
            case \ZipArchive::ER_ZIPCLOSED:
33
                return 'N Containing zip archive was closed';
34
            case \ZipArchive::ER_NOENT:
35
                return 'N No such file';
36
            case \ZipArchive::ER_EXISTS:
37
                return 'N File already exists';
38
            case \ZipArchive::ER_OPEN:
39
                return 'S Can\'t open file';
40
            case \ZipArchive::ER_TMPOPEN:
41
                return 'S Failure to create temporary file';
42
            case \ZipArchive::ER_ZLIB:
43
                return 'Z Zlib error';
44
            case \ZipArchive::ER_MEMORY:
45
                return 'N Malloc failure';
46
            case \ZipArchive::ER_CHANGED:
47
                return 'N Entry has been changed';
48
            case \ZipArchive::ER_COMPNOTSUPP:
49
                return 'N Compression method not supported';
50
            case \ZipArchive::ER_EOF:
51
                return 'N Premature EOF';
52
            case \ZipArchive::ER_INVAL:
53
                return 'N Invalid argument';
54
            case \ZipArchive::ER_NOZIP:
55
                return 'N Not a zip archive';
56
            case \ZipArchive::ER_INTERNAL:
57
                return 'N Internal error';
58
            case \ZipArchive::ER_INCONS:
59
                return 'N Zip archive inconsistent';
60
            case \ZipArchive::ER_REMOVE:
61
                return 'S Can\'t remove file';
62
            case \ZipArchive::ER_DELETED:
63
                return 'N Entry has been deleted';
64
65
            default:
66
                return sprintf('Unknown status %s', $errno);
67
        }
68
    }
69
}
70