StackName::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\kw_notify\Extend;
4
5
6
use kalanis\kw_notify\Interfaces\INotify;
7
8
9
/**
10
 * Class StackName
11
 * @package kalanis\kw_notify\Extend
12
 * Change key name in notifications
13
 */
14
class StackName implements INotify
15
{
16
    protected INotify $notify;
17
    protected string $prefix = '';
18
    protected string $suffix = '';
19
20 1
    public function __construct(INotify $storage, string $prefix = '', string $suffix = '')
21
    {
22 1
        $this->notify = $storage;
23 1
        $this->prefix = $prefix;
24 1
        $this->suffix = $suffix;
25 1
    }
26
27 1
    public function add(string $stackName, string $message): void
28
    {
29 1
        $this->notify->add($this->updateName($stackName), $message);
30 1
    }
31
32 1
    public function check(string $stackName): bool
33
    {
34 1
        return $this->notify->check($this->updateName($stackName));
35
    }
36
37 1
    public function get(string $stackName): array
38
    {
39 1
        return $this->notify->get($this->updateName($stackName));
40
    }
41
42 1
    public function reset(string $stackName): void
43
    {
44 1
        $this->notify->reset($this->updateName($stackName));
45 1
    }
46
47 1
    protected function updateName(string $stackName): string
48
    {
49 1
        return $this->prefix . $stackName . $this->suffix;
50
    }
51
}
52