Completed
Push — master ( 7b4411 )
by Bret R.
01:41
created

PhpExtensionCheck   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A check() 0 9 2
1
<?php
2
namespace BretRZaun\StatusPage\Check;
3
4
use BretRZaun\StatusPage\Result;
5
6
class PhpExtensionCheck extends AbstractCheck
7
{
8
9
    /**
10
     * @var string
11
     */
12
    protected $extension;
13
14
    /**
15
     *
16
     * @param string $label Label
17
     * @param string $extension extension to be tested
18
     */
19
    public function __construct($label, $extension)
20
    {
21
        parent::__construct($label);
22
        $this->extension = $extension;
23
    }
24
25
    /**
26
     * Check URL
27
     *
28
     * @return Result
29
     */
30
    public function check()
31
    {
32
        $result = new Result($this->label);
33
        if (!extension_loaded($this->extension)) {
34
            $result->setSuccess(false);
35
            $result->setError('Extension '.$this->extension.' is missing');
36
        }
37
        return $result;
38
    }
39
}
40