Passed
Push — master ( 2238ae...4e52d1 )
by Brian
02:41
created

BaseAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 0
f 0
dl 0
loc 31
ccs 12
cts 13
cp 0.9231
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 9 2
A shiftCursor() 0 6 1
1
<?php
2
3
namespace Bmatovu\Ussd\Actions;
4
5
use Bmatovu\Ussd\Contracts\RenderableTag;
6
use Bmatovu\Ussd\Store;
7
use Bmatovu\Ussd\Traits\Attributes;
8
use Bmatovu\Ussd\Traits\Expressions;
9
10
class BaseAction implements RenderableTag
11
{
12
    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: $attributes, $nodeValue
Loading history...
13
    use Expressions;
14
15
    protected \DOMNode $node;
16
    protected Store $store;
17
18 2
    public function __construct(\DOMNode $node, Store $store)
19
    {
20 2
        $this->node = $node;
21 2
        $this->store = $store;
22
    }
23
24 1
    public function handle(): ?string
25
    {
26 1
        $this->shiftCursor();
27
28 1
        $fails = $this->store->get('fails', 0);
29
30 1
        return $fails
31
            ? $this->readAttr('error', 'Something went wrong. Try again:')
32 1
            : $this->readAttr('text');
33
    }
34
35 1
    protected function shiftCursor(): void
36
    {
37 1
        $exp = $this->store->get('_exp');
38
39 1
        $this->store->put('_pre', $exp);
40 1
        $this->store->put('_exp', $this->incExp($exp));
41
    }
42
}
43