Test Failed
Push — master ( bfe357...41d8e8 )
by Antonio Carlos
25:24
created

src/Checkers/Cache.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 Cache as IlluminateCache;
6
use PragmaRX\Health\Support\Result;
7
8
class Cache extends Base
9
{
10
    /**
11
     * @return Result
12
     */
13
    public function check()
14
    {
15
        try {
16
            $checker = $this->getChecker();
17
18
            $value1 = $this->getCached();
19
20
            $value2 = $this->getCached();
21
22
            if ($value1 !== $value2 || $value2 !== $checker()) {
23
                return $this->makeResult(
24
                    false,
25
                    $this->target->getErrorMessage()
26
                );
27
            }
28
29
            return $this->makeHealthyResult();
30
        } catch (\Exception $exception) {
31
            report($exception);
32
33
            return $this->makeResultFromException($exception);
34
        }
35
    }
36
37
    private function getCached()
38
    {
39
        $checker = $this->getChecker();
40
41
        return IlluminateCache::remember(
42
            $this->target->key,
0 ignored issues
show
The property key 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...
43
            $this->target->minutes,
0 ignored issues
show
The property minutes 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...
44
            $checker
45
        );
46
    }
47
48
    private function getChecker()
49
    {
50
        return function () {
51
            return 'DUMMY DATA';
52
        };
53
    }
54
}
55