Completed
Push — master ( addbd6...574e3d )
by Nils
14:35
created

OnFailureExtension::process()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 3
eloc 5
nc 3
nop 2
1
<?php
2
3
namespace whm\Smoke\Extensions\SmokeOnFailure;
4
5
use Psr\Http\Message\ResponseInterface;
6
use whm\Smoke\Rules\CheckResult;
7
8
class OnFailureExtension
9
{
10
    private $callback;
11
12
    public function init($command)
13
    {
14
        $this->callback = function () use ($command) {
15
            return eval($command);
0 ignored issues
show
Coding Style introduced by
It is generally not recommended to use eval unless absolutely required.

On one hand, eval might be exploited by malicious users if they somehow manage to inject dynamic content. On the other hand, with the emergence of faster PHP runtimes like the HHVM, eval prevents some optimization that they perform.

Loading history...
16
        };
17
    }
18
19
    /**
20
     * @param CheckResult[] $results
21
     * @Event("Scanner.Scan.Validate")
22
     */
23
    public function process($results, ResponseInterface $response)
0 ignored issues
show
Unused Code introduced by
The parameter $response is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        foreach ($results as $result) {
26
            if ($result->getStatus() == CheckResult::STATUS_FAILURE) {
27
                $callback = $this->callback;
28
                $callback();
29
            }
30
        }
31
    }
32
}
33