Completed
Pull Request — master (#60)
by
unknown
01:22
created

PhpExtensionsAreDisabled::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis\Checks;
4
5
use Illuminate\Support\Collection;
6
7
class PhpExtensionsAreDisabled implements Check
8
{
9
10
    /** @var Collection */
11
    private $extensions;
12
13
    public function __construct()
14
    {
15
        $this->extensions = new Collection();
16
    }
17
18
    /**
19
     * The name of the check.
20
     *
21
     * @param array $config
22
     * @return string
23
     */
24
    public function name(array $config): string
25
    {
26
        return trans('self-diagnosis::checks.php_extensions_are_disabled.name');
27
    }
28
29
    /**
30
     * Perform the actual verification of this check.
31
     *
32
     * @param array $config
33
     * @return bool
34
     */
35
    public function check(array $config): bool
36
    {
37
        $this->extensions = Collection::make(array_get($config, 'extensions', []));
38
        $this->extensions = $this->extensions->reject(function ($ext) {
39
            return extension_loaded($ext) === false;
40
        });
41
42
        return $this->extensions->isEmpty();
43
    }
44
45
    /**
46
     * The error message to display in case the check does not pass.
47
     *
48
     * @param array $config
49
     * @return string
50
     */
51
    public function message(array $config): string
52
    {
53
        return trans('self-diagnosis::checks.php_extensions_are_disabled.message', [
54
            'extensions' => $this->extensions->implode(PHP_EOL),
55
        ]);
56
    }
57
}
58