MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/mpita.artinside.com.br/vendor/coffeecode/router/exemple/controller/Test/Name.php
<?php

namespace Test;

use CoffeeCode\Router\Router;

class Name
{
    /** @var Router */
    private Router $router;

    public function __construct($router)
    {
        $this->router = $router;
        $params = ["category" => 23213, "page" => 2];

        echo "<p>Named routes:</p>";
        echo "<nav>
            <a href='{$this->router->route("name.home")}'>Home</a> | 
            <a href='{$this->router->route("name.hello")}'>Hello</a> | 
            <a href='{$this->router->route("name.params", $params)}'>Params</a> | 
            <a href='{$this->router->route("name.redirect")}'>Redirect Back</a>
        </nav>";
    }

    public function home(): void
    {
        echo "<h3>Home</h3>";
        echo "<p>", $this->router->route("name.home"), "</p>";
        echo "<p>", $this->router->route("name.hello"), "</p>";
        echo "<p>", $this->router->route("name.redirect"), "</p>";
    }

    public function hello(): void
    {
        echo "<h3>Hello World</h3>";
        echo "<a href='{$this->router->route("name.params", ["category" => 6, "page" => 1])}'>Route Params</a>";
    }

    public function params(array $data): void
    {
        echo "<h3>Params</h3>";
        var_dump($data, $this->router->current());
    }

    public function redirect(array $data): void
    {
        if ($data) {
            $this->router->redirect("name.params", $data);
        }

        $this->router->redirect(BASE);
    }
}