Completed
Pull Request — master (#60)
by
unknown
177:15
created

PhpExtensionsAreDisabled::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 16
    public function __construct()
14
    {
15 16
        $this->extensions = new Collection();
16 16
    }
17
18
    /**
19
     * The name of the check.
20
     *
21
     * @param array $config
22
     * @return string
23
     */
24 4
    public function name(array $config): string
25
    {
26 4
        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 8
    public function check(array $config): bool
36
    {
37 8
        $this->extensions = Collection::make(array_get($config, 'extensions', []));
38 4
        $this->extensions = $this->extensions->reject(function ($ext) {
39 8
            return extension_loaded($ext) === false;
40 8
        });
41
42 8
        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 4
    public function message(array $config): string
52
    {
53 4
        return trans('self-diagnosis::checks.php_extensions_are_disabled.message', [
54 4
            'extensions' => $this->extensions->implode(PHP_EOL),
55
        ]);
56
    }
57
}
58