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

src/Checkers/Expression.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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
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