@@ -8,7 +8,7 @@ class Route
8
8
private $ routes = [];
9
9
10
10
11
- function add ($ url , $ method , $ controller , $ action )
11
+ function add (string $ url , string $ method , string $ controller , string $ action ): void
12
12
{
13
13
$ regex = '/\{([\w\-_]+)\}/i ' ;
14
14
@@ -24,7 +24,7 @@ function add($url, $method, $controller, $action)
24
24
25
25
}
26
26
27
- function match ($ requestUrl , $ requestMethod )
27
+ function match (string $ requestUrl , string $ requestMethod ): bool
28
28
{
29
29
30
30
foreach ($ this ->routes as $ route ){
@@ -47,20 +47,20 @@ function match($requestUrl, $requestMethod)
47
47
return false ;
48
48
}
49
49
50
- private function callControlerAction ($ controller , $ action , $ params )
50
+ private function callControlerAction (string $ controller , string $ action , array $ params ): void // Just echo something
51
51
{
52
52
$ controllerInstance = new $ controller ();
53
53
54
54
if (method_exists ($ controllerInstance , $ action )){
55
55
call_user_func_array ([$ controllerInstance , $ action ], [$ params ]);
56
56
} else {
57
57
58
- echo json_encode (" Internal server error! " );
58
+ echo json_encode ([ " status " => 501 , " data " => [ " massage " => " Internal server error " ]] );
59
59
}
60
60
}
61
61
62
62
63
- private function invalidRequest ($ route )
63
+ private function invalidRequest (string $ route ): void // Just echo something
64
64
{
65
65
$ response = [
66
66
"error_code " => 404 ,
0 commit comments