Passed
Push — 0.1.x ( 81ff64...72f342 )
by f
01:32
created

Bzip::getFileResource()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace wapmorgan\UnifiedArchive\Formats;
3
4
use Exception;
5
6
class Bzip extends OneFileFormat
7
{
8
    const FORMAT_SUFFIX =  'bz2';
9
10
    /**
11
     * Bzip constructor.
12
     *
13
     * @param $archiveFileName
14
     *
15
     * @throws \Exception
16
     */
17
    public function __construct($archiveFileName)
18
    {
19
        parent::__construct($archiveFileName);
20
        $this->modificationTime = filemtime($this->fileName);
21
    }
22
23
    /**
24
     * @param string $fileName
25
     *
26
     * @return string|false
27
     */
28
    public function getFileContent($fileName = null)
29
    {
30
        return bzdecompress(file_get_contents($this->fileName));
31
    }
32
33
    /**
34
     * @param string $fileName
35
     *
36
     * @return bool|resource|string
37
     */
38
    public function getFileResource($fileName = null)
39
    {
40
        return bzopen($this->fileName, 'r');
41
    }
42
43
    /**
44
     * @param $data
45
     *
46
     * @return mixed|string
47
     */
48
    protected static function compressData($data)
49
    {
50
        return bzcompress($data);
51
    }
52
}