Skip to content
This repository was archived by the owner on May 23, 2023. It is now read-only.

Commit 02a94aa

Browse files
committed
all private properties/methods are now protected
1 parent 325ae01 commit 02a94aa

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/Router.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
use Router\Http\Exceptions\InvalidRoute;
2121

2222
class Router {
23-
private array $beforeMiddleware = [];
24-
private array $afterMiddleware = [];
25-
private array $routes = [
23+
protected array $beforeMiddleware = [];
24+
protected array $afterMiddleware = [];
25+
protected array $routes = [
2626
Methods::GET->value => [],
2727
Methods::POST->value => [],
2828
Methods::PATCH->value => [],
@@ -31,17 +31,17 @@ class Router {
3131
Methods::OPTIONS->value => [],
3232
Methods::PUT->value => []
3333
];
34-
private array $E404Handlers = [];
35-
private array $E500Handlers = [];
36-
private string $baseRoute = "";
37-
private Environment $twig;
38-
private HttpServer $http;
34+
protected array $E404Handlers = [];
35+
protected array $E500Handlers = [];
36+
protected string $baseRoute = "";
37+
protected Environment $twig;
38+
protected HttpServer $http;
3939

4040
/**
4141
* @param SocketServer $socket
4242
* @param bool $dev
4343
*/
44-
public function __construct(private SocketServer $socket, private bool $dev = false) {
44+
public function __construct(protected SocketServer $socket, protected bool $dev = false) {
4545
if ($this->dev) {
4646
$this->twig = new Environment(new \Twig\Loader\FilesystemLoader(__DIR__ . "/Exceptions/views"));
4747
}
@@ -307,7 +307,7 @@ public function getSocketServer(): ?SocketServer
307307
* @throws InvalidResponse
308308
* @return ResponseInterface
309309
*/
310-
private function invoke(ServerRequestInterface $request, ?ResponseInterface $response, ?Closure $next, array $route, mixed ...$extra): ResponseInterface
310+
protected function invoke(ServerRequestInterface $request, ?ResponseInterface $response, ?Closure $next, array $route, mixed ...$extra): ResponseInterface
311311
{
312312
if (is_null($response) && !is_null($next)) {
313313
$params = [$request, $next];
@@ -343,7 +343,7 @@ private function invoke(ServerRequestInterface $request, ?ResponseInterface $res
343343
* @throws InvalidRoute
344344
* @return ResponseInterface
345345
*/
346-
private function handle(ServerRequestInterface $request): ResponseInterface
346+
protected function handle(ServerRequestInterface $request): ResponseInterface
347347
{
348348
$beforeMiddleware = $this->getMatchingRoutes($request, $this->beforeMiddleware, true)[0] ?? null;
349349
$targetRoute = $this->getMatchingRoutes($request, $this->routes[$request->getMethod()], true)[0] ?? null;
@@ -380,7 +380,7 @@ private function handle(ServerRequestInterface $request): ResponseInterface
380380
* @param array|null $matches
381381
* @return bool
382382
*/
383-
private function patternMatches(string $pattern, string $uri, array|null &$matches): bool
383+
protected function patternMatches(string $pattern, string $uri, array|null &$matches): bool
384384
{
385385
$pattern = preg_replace('/\/{(.*?)}/', '/(.*?)', $pattern);
386386

@@ -392,7 +392,7 @@ private function patternMatches(string $pattern, string $uri, array|null &$match
392392
* @param array $routes
393393
* @return array
394394
*/
395-
private function getMatchingRoutes(ServerRequest $request, array $routes, bool $findOne = false): array
395+
protected function getMatchingRoutes(ServerRequest $request, array $routes, bool $findOne = false): array
396396
{
397397
$uri = explode("?", $request->getRequestTarget())[0];
398398

0 commit comments

Comments
 (0)