feature/get-rid-of-container-usage #11
							
								
								
									
										12
									
								
								src/Interfaces/Routing/IRoute.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/Interfaces/Routing/IRoute.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,12 @@
 | 
			
		||||
<?php namespace SokoWeb\Interfaces\Routing;
 | 
			
		||||
 | 
			
		||||
interface IRoute
 | 
			
		||||
{
 | 
			
		||||
    public function getId(): string;
 | 
			
		||||
 | 
			
		||||
    public function getHandler(): array;
 | 
			
		||||
 | 
			
		||||
    public function generateLink(array $parameters = []): string;
 | 
			
		||||
 | 
			
		||||
    public function testAgainst(array $path): ?array;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										16
									
								
								src/Interfaces/Routing/IRouteCollection.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/Interfaces/Routing/IRouteCollection.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,16 @@
 | 
			
		||||
<?php namespace SokoWeb\Interfaces\Routing;
 | 
			
		||||
 | 
			
		||||
use Closure;
 | 
			
		||||
 | 
			
		||||
interface IRouteCollection
 | 
			
		||||
{
 | 
			
		||||
    public function get(string $id, string $pattern, array $handler): void;
 | 
			
		||||
 | 
			
		||||
    public function post(string $id, string $pattern, array $handler): void;
 | 
			
		||||
 | 
			
		||||
    public function group(string $pattern, Closure $group): void;
 | 
			
		||||
 | 
			
		||||
    public function getRoute(string $id): ?IRoute;
 | 
			
		||||
 | 
			
		||||
    public function match(string $method, string $uri): ?array;
 | 
			
		||||
}
 | 
			
		||||
@ -1,6 +1,8 @@
 | 
			
		||||
<?php namespace SokoWeb\Routing;
 | 
			
		||||
 | 
			
		||||
class Route
 | 
			
		||||
use SokoWeb\Interfaces\Routing\IRoute;
 | 
			
		||||
 | 
			
		||||
class Route implements IRoute
 | 
			
		||||
{
 | 
			
		||||
    private string $id;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,10 @@
 | 
			
		||||
<?php namespace SokoWeb\Routing;
 | 
			
		||||
 | 
			
		||||
use Closure;
 | 
			
		||||
use SokoWeb\Interfaces\Routing\IRoute;
 | 
			
		||||
use SokoWeb\Interfaces\Routing\IRouteCollection;
 | 
			
		||||
 | 
			
		||||
class RouteCollection
 | 
			
		||||
class RouteCollection implements IRouteCollection
 | 
			
		||||
{
 | 
			
		||||
    private array $routes = [];
 | 
			
		||||
 | 
			
		||||
@ -32,7 +34,7 @@ class RouteCollection
 | 
			
		||||
        array_pop($this->groupStack);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function getRoute(string $id): ?Route
 | 
			
		||||
    public function getRoute(string $id): ?IRoute
 | 
			
		||||
    {
 | 
			
		||||
        if (!isset($this->routes[$id])) {
 | 
			
		||||
            return null;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user