Passed
Push — 1.1.x ( dfe7d6...7e326b )
by f
02:43
created

Archive7z::supportsAllFormats()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
namespace wapmorgan\UnifiedArchive;
3
4
use Symfony\Component\Process\Process;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Process\Process was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
5
6
class Archive7z extends \Archive7z\Archive7z
0 ignored issues
show
Bug introduced by
The type Archive7z\Archive7z was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
{
8
    /**
9
     * @return false|string
10
     */
11 3
    public static function getBinaryVersion()
12
    {
13 3
        if (method_exists(__CLASS__, 'makeBinary7z'))
14
            try {
15 3
                $binary = static::makeBinary7z();
16
            } catch (\Exception $e) {
17 3
                return false;
18
            }
19
        else {
20
            // some hack for gemorroj/archive7z 4.x version
21
            try {
22
                $seven_zip = new self(null);
23
            } catch (\Exception $e) {
24
                return false;
25
            }
26
            $binary = $seven_zip->getAutoCli();
27
            unset($seven_zip);
28
        }
29
30 3
        $process = new Process([str_replace('\\', '/', $binary)]);
31 3
        $result = $process->mustRun()->getOutput();
32 3
        if (!preg_match('~7-Zip (\([a-z]\) )?(\[[\d]+\] )?(?<version>\d+\.\d+)~i', $result, $version))
33
            return false;
34
35 3
        return $version['version'];
36
    }
37
38
    /**
39
     * Hack to test if package is >=5.0.0.
40
     * setChangeSystemLocale() method was in 4.0.0 and then was removed.
41
     */
42 3
    public static function supportsAllFormats()
43
    {
44 3
        return !(method_exists(__CLASS__, 'setChangeSystemLocale'));
45
    }
46
47
//    public static function getSupportedFormats()
48
//    {
49
//
50
//    }
51
52
    /**
53
     * @param int $level 0-9 level
54
     * @return $this
55
     */
56
    public function setCompressionLevel($level)
57
    {
58
        $this->compressionLevel = $level;
0 ignored issues
show
Bug Best Practice introduced by
The property compressionLevel does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
59
        return $this;
60
    }
61
}