PhpExtensionsAreDisabled   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 46
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

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