PhpExtension   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 27
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testExists() 0 10 3
1
<?php
2
3
namespace Simplario\Checker\Checker;
4
5
use Simplario\Checker\ResultException\FailException;
6
use Simplario\Checker\ResultException\SuccessException;
7
8
/**
9
 * Class PhpExtension
10
 *
11
 * @package Simplario\Checker\Checker
12
 */
13 2
class PhpExtension extends AbstractChecker
14
{
15 2
16 1
    /**
17
     * @var string
18
     */
19 1
    protected $target = 'extension';
20
21 1
    /**
22
     * @param string  $name
23
     * @param boolean $expectExists
24
     * @param array   $task
25
     *
26
     * @throws FailException
27
     * @throws SuccessException
28
     */
29
    protected function testExists($name, $expectExists, array $task)
30
    {
31
        if (extension_loaded($name) === $expectExists) {
32
            throw new SuccessException('Ok', $task);
33
        }
34
35
        $msg = $expectExists ? "Php extension'{$name}' is not loaded'" : "Php extension '{$name}' is loaded";
36
37
        throw new FailException($msg, $task);
38
    }
39
}
40