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

PhpExtensionCheck::check()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
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