PhpExtension::testExists()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 3
crap 12
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