Test Failed
Push — master ( 892598...558941 )
by Antonio Carlos
11:17
created

Artisan::executeAndCheck()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1.037

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 2
cts 3
cp 0.6667
crap 1.037
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PragmaRX\Health\Checkers;
4
5
use Illuminate\Support\Facades\Artisan as IlluminateArtisan;
6
7
class Artisan extends Base
8
{
9
    /**
10
     * Check resource.
11
     *
12
     * @return bool
13
     */
14 1
    public function check()
15
    {
16 1
        return $this->executeAndCheck()
17
            ? $this->makeHealthyResult()
18
            : $this->makeResult(false, $this->target->getErrorMessage());
19
    }
20
21
    /**
22
     * @return bool
23
     */
24 1
    protected function executeAndCheck(): bool
25
    {
26 1
        $this->executeArtisan();
27
28
        return $this->checkArtisanOutput();
29
    }
30
31
    /**
32
     * @return bool
33
     */
34
    protected function checkArtisanOutput(): bool
35
    {
36
        $output = IlluminateArtisan::output();
37
38
        return (
39
            $output && preg_match("|{$this->target->shouldReturn}|", $output)
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...
40
        );
41
    }
42
43 1
    protected function executeArtisan(): void
44
    {
45 1
        IlluminateArtisan::call(
46 1
            $this->target->command['name'],
0 ignored issues
show
Bug introduced by
The property command 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...
47 1
            $this->target->command['options']->toArray()
48
        );
49
    }
50
}
51