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

PhpExtensionsAreDisabled   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 51
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
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\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