ToggleStatusCheck::setCache()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Leankoala\HealthFoundation\test\Check;
4
5
use Leankoala\HealthFoundation\Check\Check;
6
use Leankoala\HealthFoundation\Check\CacheAwareCheck;
7
use Leankoala\HealthFoundation\Check\Result;
8
use Leankoala\HealthFoundation\Extenstion\Cache\Cache;
9
10
class ToggleStatusCheck implements Check, CacheAwareCheck
11
{
12
    /**
13
     * @var Cache
14
     */
15
    private $cache;
16
17
    public function setCache(Cache $cache)
18
    {
19
        $this->cache = $cache;
20
    }
21
22
    public function run()
23
    {
24
        $lastStatus = $this->cache->get('status');
25
26
        if ($lastStatus === Result::STATUS_FAIL) {
27
            $this->cache->set('status', Result::STATUS_PASS);
28
            return new Result(Result::STATUS_PASS, 'Toggle to pass');
29
        } else {
30
            $this->cache->set('status', Result::STATUS_FAIL);
31
            return new Result(Result::STATUS_FAIL, 'Toggle to fail');
32
        }
33
    }
34
35
    public function getIdentifier()
36
    {
37
        return 'test.check.toggleNumber';
38
    }
39
}
40