I have the following two arrays (var_dumped
):
array (size=3)
'param' =>
array (size=1)
0 => string 'Example' (length=7)
'page-template' => string 'general' (length=7)
'action' =>
object(Closure)[2125]
array (size=3)
'param' =>
array (size=1)
0 => string 'Example' (length=7)
'page-template' => string 'general' (length=7)
'action' =>
object(Closure)[2126]
Now they are the same, they even call the same function (in 'action'
) but I cannot do ===
on them because of the closure, so I wrote this check:
foreach(self::$registeredRoutes[$routeName] as $routeActions) {
if (!is_callable($action) && !is_callable($routeActions)) {
if (isset($routeActions['param']) && isset($action['param'])
&& $routeActions['param'] === $action['param'] &&
isset($routeActions['page-template']) &&
isset($action['page-template']) &&
$routeActions['page-template'] === $action['page-template']
) {
var_dump('hello');
}
}
}
Accept it makes me want to vomit because of the if statement. Is there a cleaner, testable way of writing this where I still get the same result?