Formatting

This commit is contained in:
William 2022-01-24 12:55:37 +01:00
parent 7ee66f95d9
commit ae52c686e8
3 changed files with 10 additions and 6 deletions

View File

@ -26,7 +26,8 @@ class App
// Require model file // Require model file
require __DIR__ . '/../model/' . $model . '.php'; require __DIR__ . '/../model/' . $model . '.php';
// Instantiate model // Instantiate model
if (!$injection) { if (!$injection)
{
$injection = $this->database; $injection = $this->database;
} }
return new $model($injection); return new $model($injection);

View File

@ -7,10 +7,10 @@ class Config
public function __construct(string $path) public function __construct(string $path)
{ {
if (!file_exists($path)) { if (!file_exists($path))
{
echo("Could not find $path"); echo("Could not find $path");
throw new Exception("Could not find $path"); throw new Exception("Could not find $path");
} }
$this->config = require $path; $this->config = require $path;
} }

View File

@ -49,10 +49,12 @@ class Session
public function flash(string $msg, string $type = 'info'): void public function flash(string $msg, string $type = 'info'): void
{ {
$key = 'flashed_messages'; $key = 'flashed_messages';
if (!$this->has($key)) { if (!$this->has($key))
{
$this->set($key, []); $this->set($key, []);
} }
if (count($this->get($key)) >= 100) { if (count($this->get($key)) >= 100)
{
$this->remove($key); $this->remove($key);
throw new Exception('Too many flashed messages!'); throw new Exception('Too many flashed messages!');
} }
@ -70,7 +72,8 @@ class Session
public function getFlashedMessages(): ?array public function getFlashedMessages(): ?array
{ {
$key = 'flashed_messages'; $key = 'flashed_messages';
if ($this->has($key)) { if ($this->has($key))
{
$msgs = $this->get($key); $msgs = $this->get($key);
$this->remove($key); $this->remove($key);
return $msgs; return $msgs;