Passed
Push — master ( 0875b2...c3e6b5 )
by Brian
02:51
created

BaseAction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 92.31%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 16
dl 0
loc 32
ccs 12
cts 13
cp 0.9231
rs 10
c 2
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 9 2
A __construct() 0 4 1
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
use Bmatovu\Ussd\Traits\Variables;
10
11
class BaseAction implements RenderableTag
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: $attributes, $nodeValue
Loading history...
14
    use Expressions;
15
    use Variables;
0 ignored issues
show
Bug introduced by
The trait Bmatovu\Ussd\Traits\Variables requires the property $childNodes which is not provided by Bmatovu\Ussd\Actions\BaseAction.
Loading history...
16
17
    protected \DOMNode $node;
18
    protected Store $store;
19
20 2
    public function __construct(\DOMNode $node, Store $store)
21
    {
22 2
        $this->node = $node;
23 2
        $this->store = $store;
24
    }
25
26 1
    public function handle(): ?string
27
    {
28 1
        $this->shiftCursor();
29
30 1
        $fails = $this->store->get('fails', 0);
31
32 1
        return $fails
33
            ? $this->readAttrText('error', 'InternalError')
34 1
            : $this->readAttrText();
35
    }
36
37 1
    protected function shiftCursor(): void
38
    {
39 1
        $exp = $this->store->get('_exp');
40
41 1
        $this->store->put('_pre', $exp);
42 1
        $this->store->put('_exp', $this->incExp($exp));
43
    }
44
}
45