Skip to content

Commit 89f8939

Browse files
committed
Adding function input and return type
1 parent fa3b414 commit 89f8939

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Controllers/Route.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Route
88
private $routes = [];
99

1010

11-
function add($url, $method, $controller, $action)
11+
function add(string $url, string $method, string $controller, string $action): void
1212
{
1313
$regex = '/\{([\w\-_]+)\}/i';
1414

@@ -24,7 +24,7 @@ function add($url, $method, $controller, $action)
2424

2525
}
2626

27-
function match($requestUrl, $requestMethod)
27+
function match(string $requestUrl, string $requestMethod): bool
2828
{
2929

3030
foreach ($this->routes as $route){
@@ -47,20 +47,20 @@ function match($requestUrl, $requestMethod)
4747
return false;
4848
}
4949

50-
private function callControlerAction($controller, $action, $params)
50+
private function callControlerAction(string $controller, string $action, array $params): void // Just echo something
5151
{
5252
$controllerInstance = new $controller();
5353

5454
if (method_exists($controllerInstance, $action)){
5555
call_user_func_array([$controllerInstance, $action], [$params]);
5656
} else{
5757

58-
echo json_encode("Internal server error!");
58+
echo json_encode(["status" => 501, "data" => ["massage" => "Internal server error"]]);
5959
}
6060
}
6161

6262

63-
private function invalidRequest($route)
63+
private function invalidRequest(string $route): void // Just echo something
6464
{
6565
$response = [
6666
"error_code" => 404,

0 commit comments

Comments
 (0)