Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
IdStruct | |
100.00% |
5 / 5 |
|
100.00% |
5 / 5 |
|
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
id | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
isValid | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace Dbmi\Webservice\Quake; |
3 | |
4 | /** |
5 | * QuakeID Datastructure |
6 | * |
7 | * @param string $id |
8 | */ |
9 | class IdStruct{ |
10 | private string $id; |
11 | |
12 | public function __construct( string $id ){ |
13 | if( ! $this->isValid($id) ) |
14 | throw new \InvalidArgumentException("Quake::id not valid"); |
15 | |
16 | $this->id = $id; |
17 | } |
18 | |
19 | /** |
20 | * Get checked event id |
21 | * |
22 | * @return string event id |
23 | */ |
24 | public function id():string { return $this->id; } |
25 | |
26 | |
27 | /** |
28 | * Check if event id is valid |
29 | * |
30 | * @param string event id |
31 | * @return bool TRUE if event id is valid, FALSE otherwise |
32 | */ |
33 | private function isValid(string $id): bool { |
34 | return preg_match('/\d{6}_\d{4}_\d{3}/', $id); |
35 | } |
36 | |
37 | } |
38 | ?> |