Passed
Push — master ( 0d8a9b...48a836 )
by f
12:20
created

SplitbrainPhpArchive::checkFormatSupport()   B

Complexity

Conditions 10
Paths 7

Size

Total Lines 25
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 10
eloc 17
c 1
b 0
f 0
nc 7
nop 1
dl 0
loc 25
rs 7.6666

How to fix   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
namespace wapmorgan\UnifiedArchive\Drivers;
4
5
use wapmorgan\UnifiedArchive\Drivers\Basic\BasicDriver;
6
use wapmorgan\UnifiedArchive\Drivers\Basic\BasicPureDriver;
7
use wapmorgan\UnifiedArchive\Formats;
8
9
class SplitbrainPhpArchive extends BasicPureDriver
10
{
11
    const PACKAGE_NAME = 'splitbrain/php-archive';
12
    const MAIN_CLASS = '\\splitbrain\\PHPArchive\\Tar';
13
14
    /**
15
     * @inheritDoc
16
     */
17
    public static function getDescription()
18
    {
19
        return 'php-library for zip/tar (with gzip/bzip-compression)';
20
    }
21
22
    /**
23
     * @inheritDoc
24
     */
25
    public static function getSupportedFormats()
26
    {
27
        return [
28
            Formats::ZIP,
29
            Formats::TAR,
30
            Formats::TAR_GZIP,
31
            Formats::TAR_BZIP,
32
        ];
33
    }
34
35
    /**
36
     * @inheritDoc
37
     */
38
    public static function checkFormatSupport($format)
39
    {
40
        if (!static::isInstalled()) {
41
            return [];
42
        }
43
44
        if (
45
            ($format === Formats::TAR_BZIP && !extension_loaded('bzip2'))
46
            || ($format === Formats::TAR_GZIP && !extension_loaded('zlib'))
47
        ) {
48
            return [];
49
        }
50
51
        switch ($format) {
52
            case Formats::ZIP:
53
            case Formats::TAR:
54
            case Formats::TAR_GZIP;
55
            case Formats::TAR_BZIP;
56
                return [
57
                    BasicDriver::OPEN,
58
//                    BasicDriver::EXTRACT_CONTENT,
59
                    BasicDriver::APPEND,
60
                    BasicDriver::CREATE,
61
                    BasicDriver::CREATE_ENCRYPTED,
62
                    BasicDriver::CREATE_IN_STRING,
63
                ];
64
        }
65
    }
66
67
    /**
68
     * @inheritDoc
69
     */
70
    public function getArchiveInformation()
71
    {
72
        // TODO: Implement getArchiveInformation() method.
73
    }
74
75
    /**
76
     * @inheritDoc
77
     */
78
    public function getFileNames()
79
    {
80
        // TODO: Implement getFileNames() method.
81
    }
82
83
    /**
84
     * @inheritDoc
85
     */
86
    public function isFileExists($fileName)
87
    {
88
        // TODO: Implement isFileExists() method.
89
    }
90
91
    /**
92
     * @inheritDoc
93
     */
94
    public function getFileData($fileName)
95
    {
96
        // TODO: Implement getFileData() method.
97
    }
98
99
    /**
100
     * @inheritDoc
101
     */
102
    public function getFileContent($fileName)
103
    {
104
        // TODO: Implement getFileContent() method.
105
    }
106
107
    /**
108
     * @inheritDoc
109
     */
110
    public function getFileStream($fileName)
111
    {
112
        // TODO: Implement getFileStream() method.
113
    }
114
115
    /**
116
     * @inheritDoc
117
     */
118
    public function extractFiles($outputFolder, array $files)
119
    {
120
        // TODO: Implement extractFiles() method.
121
    }
122
123
    /**
124
     * @inheritDoc
125
     */
126
    public function extractArchive($outputFolder)
127
    {
128
        // TODO: Implement extractArchive() method.
129
    }
130
}
131