Test Failed
Push — master ( e3c39f...fe570d )
by Mihail
07:20
created

EntityCheck::checkPhpVersion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace Apps\Model\Install\Main;
4
5
use Apps\Console\MainChmodCommand;
6
use Ffcms\Core\Arch\Model;
7
use Ffcms\Core\Helper\FileSystem\Directory;
8
use Ffcms\Core\Helper\FileSystem\File;
9
use Ffcms\Core\Helper\Type\Arr;
10
use Ffcms\Core\Helper\Type\Str;
11
12
/**
13
 * Class EntityCheck. Main admin business logic model of statistics and environment status
14
 * @package Apps\Model\Install\Main
15
 */
16
class EntityCheck extends Model
17
{
18
    public $phpVersion;
19
    public $pdo;
20
    public $gd;
21
22
    private $_chmodDirs = [];
23
24
    public $chmodCheck = [];
25
26
    /**
27
    * Get default server information and prepare chmod info
28
    */
29
    public function before()
30
    {
31
        $this->phpVersion = phpversion();
32
        $this->pdo = extension_loaded('pdo');
33
        $this->gd = extension_loaded('gd') && function_exists('gd_info');
34
35
        // autoload is disabled, lets get chmod file & dirs from console app data
36
        File::inc('/Apps/Controller/Console/Main.php');
37
        $this->_chmodDirs = MainChmodCommand::$installDirs;
38
        // for each file or directory in list - check permissions
39
        foreach ($this->_chmodDirs as $object) {
40
            if (Str::endsWith('.php', $object)) { // sounds like a file
41
                $this->chmodCheck[$object] = (File::exist($object) && File::writable($object));
42
            } else {
43
                $this->chmodCheck[$object] = (Directory::exist($object) && Directory::writable($object));
44
            }
45
        }
46
    }
47
48
    /**
49
     * Check php version
50
     * @return bool
51
     */
52
    public function checkPhpVersion()
53
    {
54
        return version_compare($this->phpVersion, '5.4', '>=');
55
    }
56
57
    /**
58
     * Check all params
59
     * @return bool
60
     */
61
    public function checkAll()
62
    {
63
        return $this->checkPhpVersion() && $this->pdo && $this->gd && !Arr::in(false, $this->chmodCheck);
0 ignored issues
show
Bug introduced by zenn
false of type false is incompatible with the type double|integer|string expected by parameter $needle of Ffcms\Core\Helper\Type\Arr::in(). ( Ignorable by Annotation )

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

63
        return $this->checkPhpVersion() && $this->pdo && $this->gd && !Arr::in(/** @scrutinizer ignore-type */ false, $this->chmodCheck);
Loading history...
64
    }
65
}
66