Passed
Push — master ( 904fca...2ba06e )
by butschster
07:38
created

DefaultPatternRegistry   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A all() 0 3 1
A register() 0 3 1
1
<?php
2
3
namespace Spiral\Router\Registry;
4
5
final class DefaultPatternRegistry implements RoutePatternRegistryInterface
6
{
7
    /**
8
     * @var array<non-empty-string, non-empty-string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<non-empty-string, non-empty-string> at position 2 could not be parsed: Unknown type name 'non-empty-string' at position 2 in array<non-empty-string, non-empty-string>.
Loading history...
9
     */
10
    private array $patterns = [
11
        'int' => '\d+',
12
        'integer' => '\d+',
13
        'uuid' => '[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}',
14
    ];
15
16
    /**
17
     * @param non-empty-string $name
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...
18
     * @param non-empty-string|\Stringable $pattern
19
     */
20 1
    public function register(string $name, string|\Stringable $pattern): void
21
    {
22 1
        $this->patterns[$name] = (string)$pattern;
23
    }
24
25
    /**
26
     * @return array<non-empty-string, non-empty-string>
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<non-empty-string, non-empty-string> at position 2 could not be parsed: Unknown type name 'non-empty-string' at position 2 in array<non-empty-string, non-empty-string>.
Loading history...
27
     */
28 3
    public function all(): array
29
    {
30 3
        return $this->patterns;
31
    }
32
}
33