Passed
Push — master ( c94b56...122110 )
by Brian
12:02
created

BaseAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
dl 0
loc 37
ccs 13
cts 13
cp 1
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
A process() 0 2 1
A shiftCursor() 0 7 1
A __construct() 0 6 1
1
<?php
2
3
namespace Bmatovu\Ussd\Actions;
4
5
use Bmatovu\Ussd\Contracts\Tag;
6
use Bmatovu\Ussd\Traits\Attributes;
7
use Bmatovu\Ussd\Traits\CacheStore;
8
use Bmatovu\Ussd\Traits\Expressions;
9
use Illuminate\Contracts\Cache\Repository as CacheContract;
10
11
class BaseAction implements Tag
12
{
13
    use Attributes;
0 ignored issues
show
introduced by
The trait Bmatovu\Ussd\Traits\Attributes requires some properties which are not provided by Bmatovu\Ussd\Actions\BaseAction: $nodeValue, $attributes
Loading history...
14
    use CacheStore;
15
    use Expressions;
16
17
    protected \DOMNode $node;
18
    protected CacheContract $cache;
19
    protected string $prefix;
20
    protected int $ttl;
21
22 2
    public function __construct(\DOMNode $node, CacheContract $cache, string $prefix, ?int $ttl = null)
23
    {
24 2
        $this->node = $node;
25 2
        $this->cache = $cache;
26 2
        $this->prefix = $prefix;
27 2
        $this->ttl = $ttl;
28
    }
29
30 1
    public function handle(): ?string
31
    {
32 1
        $this->shiftCursor();
33
34 1
        return '';
35
    }
36
37
    public function process(?string $answer): void
38
    {
39
    }
40
41 1
    protected function shiftCursor(): void
42
    {
43 1
        $pre = $this->fromCache('pre');
0 ignored issues
show
Unused Code introduced by
The assignment to $pre is dead and can be removed.
Loading history...
44 1
        $exp = $this->fromCache('exp', $this->node->getNodePath());
45
46 1
        $this->toCache('pre', $exp);
47 1
        $this->toCache('exp', $this->incExp($exp));
48
    }
49
}
50