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

DefaultPatternRegistry::all()   A

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
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 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