Skip to content

Commit 7addd56

Browse files
committed
Merge branch 'dev'
2 parents 3428878 + 9339f53 commit 7addd56

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

system/core/Router.php

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,22 @@
33
use Ligne\ErrorHandler;
44

55
/**
6-
  * This class controls even if a driver has been entered in the url
7-
  * nonexistent or a controller method that does not exist with the following hierarchy:
8-
  *
9-
  * http: // host / controller / action / [parameter]
10-
  * ^ ^
11-
  * 1st verify 2nd verify
12-
  *
13-
  * Until the first condition of this is not given, it does not continue, this being a way
14-
  * make sure the controller is correct to verify
15-
  * that the method be part of that controller.
16-
  *
17-
  * The router takes the url captured by request.php and exploits the url in 3
18-
  * different parts in the "/" character:
19-
  *
20-
  **/
6+
* This class controls even if a driver has been entered in the url
7+
* nonexistent or a controller method that does not exist with the following hierarchy:
8+
*
9+
* http: // host / controller / action / [parameter]
10+
* ^ ^
11+
* 1st verify 2nd verify
12+
*
13+
* Until the first condition of this is not given, it does not continue, this being a way
14+
* make sure the controller is correct to verify
15+
* that the method be part of that controller.
16+
*
17+
* The router takes the url captured by request.php and exploits the url in 3
18+
* different parts in the "/" character:
19+
*
20+
**/
21+
2122
class Router
2223
{
2324
/**
@@ -37,20 +38,20 @@ static public function parse(string $url, object $request): void
3738
if ($url == '/' . self::rootDir() . '/' || $controllerName === null)
3839
self::loadIndex($request);
3940
elseif ($controllerName !== null && $actionNAme !== null)
40-
self::routeConstruct($request, $controllerName,$actionNAme,$params);
41+
self::routeConstruct($request, $controllerName, $actionNAme, $params);
4142
else
4243
self::showNonexistentController($controllerName);
4344
}
4445

4546
/**
4647
* Construct the route base on URL
47-
*
48+
*
4849
* @param object $request
4950
* @param string $controllerName
5051
* @param string $actionName
5152
* @param array $params
5253
*/
53-
static private function routeConstruct(object $request, string $controllerName,string $actionName,array $params): void
54+
static private function routeConstruct(object $request, string $controllerName, string $actionName, array $params): void
5455
{
5556
$request->controller = $controllerName;
5657
$request->action = $actionName;
@@ -144,7 +145,7 @@ static public function subtractControllerName($url)
144145
$explodeUrl = explode('/', $url);
145146
$explodeRootDir = explode('/', __ROOT__DIR__);
146147

147-
$explodeUrl = self::unsertKeysFromSourceArray($explodeUrl,$explodeRootDir);
148+
$explodeUrl = self::unsertKeysFromSourceArray($explodeUrl, $explodeRootDir);
148149

149150
$explodeUrl = array_values($explodeUrl);
150151
return isset($explodeUrl[0]) ? $explodeUrl[0] : null;
@@ -155,18 +156,18 @@ static public function subtractActionName($url)
155156
$explodeUrl = explode('/', $url);
156157
$explodeRootDir = explode('/', __ROOT__DIR__);
157158

158-
$explodeUrl = self::unsertKeysFromSourceArray($explodeUrl,$explodeRootDir);
159+
$explodeUrl = self::unsertKeysFromSourceArray($explodeUrl, $explodeRootDir);
159160

160161
$explodeUrl = array_values($explodeUrl);
161162
return isset($explodeUrl[1]) ? $explodeUrl[1] : null;
162163
}
163164

164-
static public function subtractParams($url):array
165+
static public function subtractParams($url): array
165166
{
166167
$explodeUrl = explode('/', $url);
167168
$explodeRootDir = explode('/', __ROOT__DIR__);
168169

169-
$params = self::unsertKeysFromSourceArray($explodeUrl,$explodeRootDir);
170+
$params = self::unsertKeysFromSourceArray($explodeUrl, $explodeRootDir);
170171

171172
$params = array_values($explodeUrl);
172173
//Exclude the controller and action from url
@@ -187,7 +188,8 @@ static public function subtractParams($url):array
187188
* Unsert project "values" from the $url for determinate if the user specific the
188189
* controller, action and params
189190
*/
190-
static private function unsertKeysFromSourceArray(array $source, array $target){
191+
static private function unsertKeysFromSourceArray(array $source, array $target)
192+
{
191193
foreach ($source as $key => $value) {
192194
if (in_array($value, $target)) {
193195
unset($source[$key]);

0 commit comments

Comments
 (0)