Passed
Push — master ( 57f692...abb7a8 )
by Mihail
04:20
created

EntityCheck::checkAll()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 4
rs 9.2
cc 4
eloc 2
nc 4
nop 0
1
<?php
2
3
namespace Apps\Model\Install\Main;
4
5
use Apps\Controller\Console\Main;
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
class EntityCheck extends Model
13
{
14
    public $phpVersion;
15
    public $pdo;
16
    public $gd;
17
18
    private $_chmodDirs = [];
19
20
    public $chmodCheck = [];
21
22
    /**
23
    * Get default server information and prepare chmod info
24
    */
25
    public function before()
26
    {
27
        $this->phpVersion = phpversion();
28
        $this->pdo = extension_loaded('pdo');
29
        $this->gd = extension_loaded('gd') && function_exists('gd_info');
30
31
        // autoload is disabled, lets get chmod file & dirs from console app data
32
        File::inc('/Apps/Controller/Console/Main.php');
0 ignored issues
show
Bug introduced by
The method inc() does not seem to exist on object<Ffcms\Core\Helper\FileSystem\File>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33
        $this->_chmodDirs = Main::$installDirs;
34
        // for each file or directory in list - check permissions
35
        foreach ($this->_chmodDirs as $object) {
36
            if (Str::endsWith('.php', $object)) { // sounds like a file
37
                $this->chmodCheck[$object] = (File::exist($object) && File::writable($object));
38
            } else {
39
                $this->chmodCheck[$object] = (Directory::exist($object) && Directory::writable($object));
0 ignored issues
show
Bug introduced by
The method writable() does not seem to exist on object<Ffcms\Core\Helper\FileSystem\Directory>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
40
            }
41
        }
42
    }
43
44
    /**
45
     * Check php version
46
     * @return bool
47
     */
48
    public function checkPhpVersion()
49
    {
50
        return version_compare($this->phpVersion, '5.4', '>=');
51
    }
52
53
    /**
54
     * Check all params
55
     * @return bool
56
     */
57
    public function checkAll()
58
    {
59
        return $this->checkPhpVersion() && $this->pdo && $this->gd && !Arr::in(false, $this->chmodCheck);
0 ignored issues
show
Documentation introduced by
false is of type boolean, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
    }
61
}