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

PhpExtensionsAreDisabled   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 46
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\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