Skip to content

Commit 8a926a8

Browse files
committed
Change default timezone
1 parent 0f8c130 commit 8a926a8

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
SLACK_API_WEBHOOK=Your_webhook_here
2+
3+
DEFAULT_DATE_TIMEZONE=America/Sao_Paulo

app/Date/index.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
date_default_timezone_set(getenv('DEFAULT_DATE_TIMEZONE'));

app/Route/Router.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ final class Router implements RouterInterface
1717

1818
public function dispatch(string $uri, array $params = []): void
1919
{
20-
if (key_exists($uri, $this->routes)) {
21-
$uriContent = $this->routes[$uri];
22-
$reflectedControllerMethod = self::createReflectionMethod($uriContent);
23-
$reflectedControllerMethod->invokeArgs(new $uriContent['namespace'], $params);
20+
if (!key_exists($uri, $this->routes)) {
21+
throw new InvalidArgumentException("'{$uri}' is an unregistered route", StatusCodeEnum::NOT_FOUND());
2422
}
2523

26-
throw new InvalidArgumentException("'{$uri}' is an unregistered route", StatusCodeEnum::NOT_FOUND());
24+
$uriContent = $this->routes[$uri];
25+
$reflectedControllerMethod = self::createReflectionMethod($uriContent);
26+
$reflectedControllerMethod->invokeArgs(new $uriContent['namespace'], $params);
2727
}
2828

2929
public function registry(string $uri, string $controller, string $method): void

bootstrap/index.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3-
require_once __DIR__ . '/../app/Route/index.php';
4-
53
require_once __DIR__ . '/../app/DotEnvLoader/index.php';
4+
5+
require_once __DIR__ . '/../app/Date/index.php';
6+
7+
require_once __DIR__ . '/../app/Route/index.php';

0 commit comments

Comments
 (0)