Passed
Push — main ( 438344...ee0fb9 )
by Thomas
02:54
created

RegistryTag   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 5
c 1
b 0
f 0
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A has() 0 3 1
A get() 0 3 1
A entry() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Conia\Chuck;
6
7
class RegistryTag
8
{
9
    /**
10
     * @param non-empty-string $id
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
11
     * */
12 3
    public function __construct(
13
        readonly protected string $tag,
14
        readonly protected Registry $registry,
15
    ) {
16 3
    }
17
18 1
    public function has(string $id): mixed
19
    {
20 1
        return $this->registry->hasTagged($this->tag, $id);
21
    }
22
23 2
    public function entry(string $id): RegistryEntry
24
    {
25 2
        return $this->registry->taggedEntry($this->tag, $id);
26
    }
27
28 2
    public function get(string $id): mixed
29
    {
30 2
        return $this->registry->getTagged($this->tag, $id);
31
    }
32
33
    /**
34
     * @param non-empty-string $id
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
35
     */
36 2
    public function add(string $id, mixed $value = null): RegistryEntry
37
    {
38 2
        return $this->registry->addTagged($this->tag, $id, $value);
39
    }
40
}
41