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 55namespace Coduo \PHPMatcher \Matcher \Pattern ;
66
77use Coduo \PHPMatcher \Exception \UnknownTypeException ;
8+ use Coduo \PHPMatcher \Matcher \UuidMatcher ;
89
910final class RegexConverter
1011{
@@ -21,6 +22,8 @@ public function toRegex(TypePattern $typePattern) : string
2122 return '( \\-?[0-9]*) ' ;
2223 case 'double ' :
2324 return '( \\-?[0-9]*[ \\.| \\,][0-9]*) ' ;
25+ case 'uuid ' :
26+ return '( ' .UuidMatcher::UUID_PATTERN .') ' ;
2427 default :
2528 throw new UnknownTypeException ($ typePattern ->getType ());
2629 }
Original file line number Diff line number Diff line change 1010final class UuidMatcher extends Matcher
1111{
1212 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 .'$| ' ;
1415
1516 private $ parser ;
1617
Original file line number Diff line number Diff line change @@ -107,6 +107,16 @@ public function matchingData()
107107 '/users/12345/active ' ,
108108 '/users/@integer@.greaterThan(0)/active ' ,
109109 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
110120 ]
111121 ];
112122 }
You can’t perform that action at this time.
0 commit comments