File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 5
5
namespace Coduo \PHPMatcher \Matcher \Pattern ;
6
6
7
7
use Coduo \PHPMatcher \Exception \UnknownTypeException ;
8
+ use Coduo \PHPMatcher \Matcher \UuidMatcher ;
8
9
9
10
final class RegexConverter
10
11
{
@@ -21,6 +22,8 @@ public function toRegex(TypePattern $typePattern) : string
21
22
return '( \\-?[0-9]*) ' ;
22
23
case 'double ' :
23
24
return '( \\-?[0-9]*[ \\.| \\,][0-9]*) ' ;
25
+ case 'uuid ' :
26
+ return '( ' .UuidMatcher::UUID_PATTERN .') ' ;
24
27
default :
25
28
throw new UnknownTypeException ($ typePattern ->getType ());
26
29
}
Original file line number Diff line number Diff line change 10
10
final class UuidMatcher extends Matcher
11
11
{
12
12
const PATTERN = 'uuid ' ;
13
- const UUID_FORMAT_PATTERN = '|^[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$| ' ;
13
+ const UUID_PATTERN = '[\da-f]{8}-[\da-f]{4}-[1-5][\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12} ' ;
14
+ const UUID_FORMAT_PATTERN = '|^ ' .self ::UUID_PATTERN .'$| ' ;
14
15
15
16
private $ parser ;
16
17
Original file line number Diff line number Diff line change @@ -107,6 +107,16 @@ public function matchingData()
107
107
'/users/12345/active ' ,
108
108
'/users/@[email protected] (0)/active ' ,
109
109
true
110
+ ],
111
+ [
112
+ '/user/ebd1fb0e-45ae-11e8-842f-0ed5f89f718b/profile ' ,
113
+ '/user/@uuid@/@string@ ' ,
114
+ true
115
+ ],
116
+ [
117
+ '/user/12345/profile ' ,
118
+ '/user/@uuid@/@string@ ' ,
119
+ false
110
120
]
111
121
];
112
122
}
You can’t perform that action at this time.
0 commit comments