File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -57,5 +57,5 @@ And you will see the result: 123
5757You can run this route in CLI mode
5858
5959``` shell
60- php .\i ndex.php /teste/123
60+ php .\i ndex.php GET /teste/123
6161```
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ public function getDynamicParameters(Route $acessedRoute) : RouteParameters
5454 }
5555 }
5656 }
57+
5758 return $ parameters ;
5859 }
5960}
Original file line number Diff line number Diff line change @@ -14,9 +14,10 @@ public function controllers(array $controllers = [])
1414 {
1515 $ this ->controllers = $ controllers ;
1616 $ this ->run ();
17+ return $ this ;
1718 }
1819
19- public function run ()
20+ private function run ()
2021 {
2122 $ acessedRoute = $ this ->getAccessedRoute ();
2223
@@ -35,17 +36,17 @@ public function run()
3536 }
3637 }
3738 }
38-
39- public function isCli ()
39+
40+ private function isCli ()
4041 {
4142 return php_sapi_name () === 'cli ' ;
4243 }
4344
44- public function getAccessedRoute ()
45+ private function getAccessedRoute ()
4546 {
4647 global $ argv ;
47- $ route = $ this ->isCli () ? $ argv [1 ] : $ _SERVER ['REQUEST_URI ' ];
48- $ method = $ this ->isCli () ? " GET " : $ _SERVER ['REQUEST_METHOD ' ];
48+ $ route = $ this ->isCli () ? $ argv [2 ] : explode ( " ? " , $ _SERVER ['REQUEST_URI ' ])[ 0 ];
49+ $ method = $ this ->isCli () ? $ argv [ 1 ] : explode ( " ? " , $ _SERVER ['REQUEST_METHOD ' ])[ 0 ];
4950
5051 return new Route ($ route , $ method );
5152 }
You can’t perform that action at this time.
0 commit comments