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

Cache   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 10
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check() 0 23 4
A getCached() 0 10 1
A getChecker() 0 6 1
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
Bug introduced by
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
Bug introduced by
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