Completed
Pull Request — master (#28)
by
unknown
01:27
created

PhpExtensionsAreDisabled::check()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 1
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
    /**
14
     * The name of the check.
15
     *
16
     * @param array $config
17
     * @return string
18
     */
19
    public function name(array $config): string
20
    {
21
        return trans('self-diagnosis::checks.php_extensions_are_disabled.name');
22
    }
23
24
    /**
25
     * Perform the actual verification of this check.
26
     *
27
     * @param array $config
28
     * @return bool
29
     */
30
    public function check(array $config): bool
31
    {
32
        $this->extensions = Collection::make(array_get($config, 'extensions', []));
33
        $this->extensions = $this->extensions->reject(function ($ext) {
34
            return extension_loaded($ext) === false;
35
        });
36
37
        return $this->extensions->isEmpty();
38
    }
39
40
    /**
41
     * The error message to display in case the check does not pass.
42
     *
43
     * @param array $config
44
     * @return string
45
     */
46
    public function message(array $config): string
47
    {
48
        return trans('self-dianosis::checks.php_extensions_are_disabled.message', [
49
            'extensions' => $this->extensions->implode(PHP_EOL),
50
        ]);
51
    }
52
}
53