Skip to content

Commit c8bac1f

Browse files
committed
fix/query-strings
1 parent 3ce69d6 commit c8bac1f

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,5 @@ And you will see the result: 123
5757
You can run this route in CLI mode
5858

5959
```shell
60-
php .\index.php /teste/123
60+
php .\index.php GET /teste/123
6161
```

src/Route.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function getDynamicParameters(Route $acessedRoute) : RouteParameters
5454
}
5555
}
5656
}
57+
5758
return $parameters;
5859
}
5960
}

src/Router.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)