Passed
Push — master ( e32a81...12baf4 )
by Antonio Carlos
02:26
created

Expression   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
dl 0
loc 36
ccs 13
cts 14
cp 0.9286
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 6 2
A expressionIsOk() 0 16 3
A executeExpression() 0 4 1
1
<?php
2
3
namespace PragmaRX\Health\Checkers;
4
5
use PragmaRX\Health\Support\Result;
6
7
class Expression extends Base
8
{
9
    /**
10
     * Check resource.
11
     *
12
     * @return Result
13
     */
14 1
    public function check()
15
    {
16 1
        return $this->expressionIsOk()
17 1
            ? $this->makeHealthyResult()
18 1
            : $this->makeResult(false, $this->target->getErrorMessage());
19
    }
20
21 1
    public function expressionIsOk()
22
    {
23 1
        $expressionResult = $this->executeExpression(
24 1
            $this->target->expressionValue
0 ignored issues
show
Bug introduced by
The property expressionValue does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
25
        );
26
27 1
        if ($this->target->shouldReturn === true) {
0 ignored issues
show
Bug introduced by
The property shouldReturn does not seem to exist in PragmaRX\Health\Support\Target.

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
28 1
            return (bool) $expressionResult;
29
        }
30
31 1
        if ($this->target->shouldReturn === false) {
32 1
            return ! $expressionResult;
33
        }
34
35
        return preg_match("|{$this->target->shouldReturn}|", $expressionResult);
36
    }
37
38 1
    public function executeExpression($expression)
39
    {
40 1
        return eval("return {$expression} ;");
41
    }
42
}
43