@@ -90,7 +90,19 @@ public static function addRoute(Route $route): void
9090 self ::$ routes [$ route ->getMethod ()][$ path ] = $ route ;
9191
9292 foreach ($ route ->getAdditionalMethods () as $ method ) {
93- self ::addRouteMethod ($ method , $ route );
93+ if (!\array_key_exists ($ method , self ::$ routes )) {
94+ throw new Exception ("Method ( {$ method }) not supported. " );
95+ }
96+
97+ if ($ route ->getPath () === '' ) {
98+ throw new Exception ('Additional route methods are not supported for the wildcard route. ' );
99+ }
100+
101+ if (\array_key_exists ($ path , self ::$ routes [$ method ]) && !self ::$ allowOverride ) {
102+ throw new Exception ("Route for ( {$ method }: {$ path }) already registered. " );
103+ }
104+
105+ self ::$ routes [$ method ][$ path ] = $ route ;
94106 }
95107 }
96108
@@ -120,34 +132,6 @@ public static function addRouteAlias(string $path, Route $route, ?string $method
120132 self ::$ routes [$ method ][$ alias ] = $ route ;
121133 }
122134
123- /**
124- * Register a route under an additional HTTP method, using its own path.
125- *
126- * @throws \Exception
127- */
128- public static function addRouteMethod (string $ method , Route $ route ): void
129- {
130- if (!\array_key_exists ($ method , self ::$ routes )) {
131- throw new Exception ("Method ( {$ method }) not supported. " );
132- }
133-
134- if ($ route ->getPath () === '' ) {
135- throw new Exception ('Additional route methods are not supported for the wildcard route. ' );
136- }
137-
138- [$ path , $ params ] = self ::preparePath ($ route ->getPath ());
139-
140- if (\array_key_exists ($ path , self ::$ routes [$ method ]) && !self ::$ allowOverride ) {
141- throw new Exception ("Route for ( {$ method }: {$ path }) already registered. " );
142- }
143-
144- foreach ($ params as $ key => $ index ) {
145- $ route ->setPathParam ($ key , $ index , $ path );
146- }
147-
148- self ::$ routes [$ method ][$ path ] = $ route ;
149- }
150-
151135 /**
152136 * Register a method-agnostic catch-all route, used when nothing else matches.
153137 */
0 commit comments