Passed
Push — 1.1.x ( 3d3019...6d4a67 )
by f
02:55 queued 01:04
created

BasicDriver::canAddFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
namespace wapmorgan\UnifiedArchive\Drivers;
3
4
use wapmorgan\UnifiedArchive\ArchiveEntry;
5
use wapmorgan\UnifiedArchive\ArchiveInformation;
6
use wapmorgan\UnifiedArchive\Exceptions\ArchiveCreationException;
7
use wapmorgan\UnifiedArchive\Exceptions\ArchiveExtractionException;
8
use wapmorgan\UnifiedArchive\Exceptions\ArchiveModificationException;
9
use wapmorgan\UnifiedArchive\Exceptions\UnsupportedArchiveException;
10
use wapmorgan\UnifiedArchive\Exceptions\UnsupportedOperationException;
11
use wapmorgan\UnifiedArchive\PclzipZipInterface;
12
13
abstract class BasicDriver
14
{
15
    const COMPRESSION_NONE = 0;
16
    const COMPRESSION_WEAK = 1;
17
    const COMPRESSION_AVERAGE = 2;
18
    const COMPRESSION_STRONG = 3;
19
    const COMPRESSION_MAXIMUM = 4;
20
21
    /**
22
     * @return array
23
     */
24
    public static function getSupportedFormats()
25
    {
26
        return [];
27
    }
28
29
    /**
30
     * @param $format
31
     * @return bool
32
     */
33
    public static function checkFormatSupport($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public static function checkFormatSupport(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        return false;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public static function getDescription()
42
    {
43
        return null;
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public static function getInstallationInstruction()
50
    {
51
        return null;
52
    }
53
54
    /**
55
     * @param $format
56
     * @return bool
57
     */
58
    public static function canCreateArchive($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

58
    public static function canCreateArchive(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        return false;
61
    }
62
63
    /**
64
     * @param $format
65
     * @return bool
66
     */
67
    public static function canAddFiles($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

67
    public static function canAddFiles(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
68
    {
69
        return false;
70
    }
71
72
    /**
73
     * @param $format
74
     * @return bool
75
     */
76
    public static function canDeleteFiles($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

76
    public static function canDeleteFiles(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
77
    {
78
        return false;
79
    }
80
81
    /**
82
     * @param $format
83
     * @return false
84
     */
85
    public static function canEncrypt($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

85
    public static function canEncrypt(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
86
    {
87
        return false;
88
    }
89
90
    /**
91
     * @param $format
92
     * @return false
93
     */
94
    public static function canStream($format)
0 ignored issues
show
Unused Code introduced by
The parameter $format is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

94
    public static function canStream(/** @scrutinizer ignore-unused */ $format)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
95
    {
96
        return false;
97
    }
98
99
    /**
100
     * @param array $files
101
     * @param string $archiveFileName
102
     * @param int $compressionLevel
103
     * @param null $password
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $password is correct as it would always require null to be passed?
Loading history...
104
     * @return int Number of archived files
105
     * @throws UnsupportedOperationException
106
     */
107
    public static function createArchive(array $files, $archiveFileName, $compressionLevel = self::COMPRESSION_AVERAGE, $password = null)
0 ignored issues
show
Unused Code introduced by
The parameter $password is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

107
    public static function createArchive(array $files, $archiveFileName, $compressionLevel = self::COMPRESSION_AVERAGE, /** @scrutinizer ignore-unused */ $password = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $archiveFileName is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

107
    public static function createArchive(array $files, /** @scrutinizer ignore-unused */ $archiveFileName, $compressionLevel = self::COMPRESSION_AVERAGE, $password = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $files is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

107
    public static function createArchive(/** @scrutinizer ignore-unused */ array $files, $archiveFileName, $compressionLevel = self::COMPRESSION_AVERAGE, $password = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $compressionLevel is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

107
    public static function createArchive(array $files, $archiveFileName, /** @scrutinizer ignore-unused */ $compressionLevel = self::COMPRESSION_AVERAGE, $password = null)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
108
    {
109
        throw new UnsupportedOperationException();
110
    }
111
112
    /**
113
     * BasicDriver constructor.
114
     * @param string $archiveFileName
115
     * @param string $format
116
     * @param string|null $password Archive password for opening
117
     */
118
    abstract public function __construct($archiveFileName, $format, $password = null);
119
120
    /**
121
     * Returns summary about an archive.
122
     * Called after
123
     * - constructing
124
     * - addFiles()
125
     * - deleteFiles()
126
     * @return ArchiveInformation
127
     */
128
    abstract public function getArchiveInformation();
129
130
    /**
131
     * @return array
132
     */
133
    abstract public function getFileNames();
134
135
    /**
136
     * @param string $fileName
137
     * @return bool
138
     */
139
    abstract public function isFileExists($fileName);
140
141
    /**
142
     * @param string $fileName
143
     * @return ArchiveEntry|false
144
     */
145
    abstract public function getFileData($fileName);
146
147
    /**
148
     * @param string $fileName
149
     * @return string|false
150
     */
151
    abstract public function getFileContent($fileName);
152
153
    /**
154
     * @param string $fileName
155
     * @return resource
156
     */
157
    abstract public function getFileStream($fileName);
158
159
    /**
160
     * @param $string
161
     * @return resource
162
     */
163 6
    public static function wrapStringInStream($string)
164
    {
165 6
        $resource = fopen('php://temp', 'r+');
166 6
        fwrite($resource, $string);
167 6
        rewind($resource);
168 6
        return $resource;
169
    }
170
171
    /**
172
     * @param string $outputFolder
173
     * @param array  $files
174
     * @return int Number of extracted files
175
     * @throws ArchiveExtractionException
176
     */
177
    abstract public function extractFiles($outputFolder, array $files);
178
179
    /**
180
     * @param string $outputFolder
181
     * @return int Number of extracted files
182
     * @throws ArchiveExtractionException
183
     */
184
    abstract public function extractArchive($outputFolder);
185
186
    /**
187
     * @param array $files
188
     * @return false|int Number of deleted files
189
     * @throws UnsupportedOperationException
190
     * @throws ArchiveModificationException
191
     */
192
    public function deleteFiles(array $files)
0 ignored issues
show
Unused Code introduced by
The parameter $files is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

192
    public function deleteFiles(/** @scrutinizer ignore-unused */ array $files)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
193
    {
194
        throw new UnsupportedOperationException();
195
    }
196
197
    /**
198
     * @param array $files
199
     * @return int Number of added files
200
     * @throws UnsupportedOperationException
201
     * @throws ArchiveModificationException
202
     */
203
    public function addFiles(array $files)
0 ignored issues
show
Unused Code introduced by
The parameter $files is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

203
    public function addFiles(/** @scrutinizer ignore-unused */ array $files)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
204
    {
205
        throw new UnsupportedOperationException();
206
    }
207
208
    /**
209
     * @param string $inArchiveName
210
     * @param string $content
211
     * @return bool
212
     * @throws UnsupportedOperationException
213
     * @throws ArchiveModificationException
214
     */
215
    abstract public function addFileFromString($inArchiveName, $content);
216
217
    /**
218
     * @return string|null
219
     */
220
    public function getComment()
221
    {
222
        return null;
223
    }
224
225
    /**
226
     * @param string|null $comment
227
     * @return null
228
     */
229
    public function setComment($comment)
0 ignored issues
show
Unused Code introduced by
The parameter $comment is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

229
    public function setComment(/** @scrutinizer ignore-unused */ $comment)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
230
    {
231
        return null;
232
    }
233
}