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

PhpExtensionCheck::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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