summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2019-11-10 23:26:23 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2019-11-11 00:05:41 +0100
commit68afc74b03f83bb072944911c15af60433280ace (patch)
tree1217a5cbfa75c01d35e8e0d743da379725816bf2 /src
parentb878740f80ce7cfe2a0bc53956e3f7e4e0aa2f78 (diff)
Formatting to follow PSR-12
Diffstat (limited to 'src')
-rw-r--r--src/Controllers/Metrics/MetricsEngine.php6
-rw-r--r--src/Controllers/PasswordResetController.php8
-rw-r--r--src/Database/Migration/Migrate.php7
-rw-r--r--src/Exceptions/Handler.php7
-rw-r--r--src/Exceptions/Handlers/Legacy.php2
-rw-r--r--src/Exceptions/Handlers/LegacyDevelopment.php6
-rw-r--r--src/Http/Validation/ValidatesRequest.php6
-rw-r--r--src/Middleware/LegacyMiddleware.php5
-rw-r--r--src/Models/LogEntry.php2
-rw-r--r--src/Models/User/PasswordReset.php2
-rw-r--r--src/helpers.php1
11 files changed, 35 insertions, 17 deletions
diff --git a/src/Controllers/Metrics/MetricsEngine.php b/src/Controllers/Metrics/MetricsEngine.php
index 21ae8fd0..8301e388 100644
--- a/src/Controllers/Metrics/MetricsEngine.php
+++ b/src/Controllers/Metrics/MetricsEngine.php
@@ -137,10 +137,12 @@ class MetricsEngine implements EngineInterface
}
/**
- * Does nothing as shared data will onyly result in unexpected behaviour
+ * Does nothing as shared data will only result in unexpected behaviour
*
* @param string|mixed[] $key
* @param mixed $value
*/
- public function share($key, $value = null) { }
+ public function share($key, $value = null)
+ {
+ }
}
diff --git a/src/Controllers/PasswordResetController.php b/src/Controllers/PasswordResetController.php
index a1460104..6ceadec1 100644
--- a/src/Controllers/PasswordResetController.php
+++ b/src/Controllers/PasswordResetController.php
@@ -74,7 +74,7 @@ class PasswordResetController extends BaseController
/** @var User $user */
$user = User::whereEmail($data['email'])->first();
if ($user) {
- $reset = (new PasswordReset)->findOrNew($user->id);
+ $reset = (new PasswordReset())->findOrNew($user->id);
$reset->user_id = $user->id;
$reset->token = md5(random_bytes(64));
$reset->save();
@@ -120,8 +120,10 @@ class PasswordResetController extends BaseController
]);
if ($data['password'] !== $data['password_confirmation']) {
- $this->session->set('errors',
- array_merge($this->session->get('errors', []), ['validation.password.confirmed']));
+ $this->session->set(
+ 'errors',
+ array_merge($this->session->get('errors', []), ['validation.password.confirmed'])
+ );
return $this->showView('pages/password/reset-form');
}
diff --git a/src/Database/Migration/Migrate.php b/src/Database/Migration/Migrate.php
index 214903e4..a0d5d4b0 100644
--- a/src/Database/Migration/Migrate.php
+++ b/src/Database/Migration/Migrate.php
@@ -11,8 +11,11 @@ use Illuminate\Support\Str;
class Migrate
{
- const UP = 'up';
- const DOWN = 'down';
+ /** @var string */
+ public const UP = 'up';
+
+ /** @var string */
+ public const DOWN = 'down';
/** @var Application */
protected $app;
diff --git a/src/Exceptions/Handler.php b/src/Exceptions/Handler.php
index b3d840c0..f8905531 100644
--- a/src/Exceptions/Handler.php
+++ b/src/Exceptions/Handler.php
@@ -18,8 +18,11 @@ class Handler
/** @var Request */
protected $request;
- const ENV_PRODUCTION = 'prod';
- const ENV_DEVELOPMENT = 'dev';
+ /** @var string */
+ public const ENV_PRODUCTION = 'prod';
+
+ /** @var string */
+ public const ENV_DEVELOPMENT = 'dev';
/**
* Handler constructor.
diff --git a/src/Exceptions/Handlers/Legacy.php b/src/Exceptions/Handlers/Legacy.php
index 461dabe1..45285a8d 100644
--- a/src/Exceptions/Handlers/Legacy.php
+++ b/src/Exceptions/Handlers/Legacy.php
@@ -13,7 +13,7 @@ class Legacy implements HandlerInterface
*/
public function render($request, Throwable $e)
{
- echo 'An <del>un</del>expected error occurred, a team of untrained monkeys has been dispatched to deal with it.';
+ echo 'An <del>un</del>expected error occurred. A team of untrained monkeys has been dispatched to fix it.';
}
/**
diff --git a/src/Exceptions/Handlers/LegacyDevelopment.php b/src/Exceptions/Handlers/LegacyDevelopment.php
index cfa4efa4..d6a11949 100644
--- a/src/Exceptions/Handlers/LegacyDevelopment.php
+++ b/src/Exceptions/Handlers/LegacyDevelopment.php
@@ -15,7 +15,11 @@ class LegacyDevelopment extends Legacy
{
$file = $this->stripBasePath($e->getFile());
- echo '<pre style="background-color:#333;color:#ccc;z-index:1000;position:fixed;bottom:1em;padding:1em;width:97%;max-height: 90%;overflow-y:auto;">';
+ echo sprintf(
+ '<pre style="%s">',
+ 'background-color:#333;color:#ccc;z-index:1000;position:fixed;'
+ . 'bottom:1em;padding:1em;width:97%;max-height:90%;overflow-y:auto;'
+ );
echo sprintf('%s: (%s)' . PHP_EOL, get_class($e), $e->getCode());
$data = [
'string' => $e->getMessage(),
diff --git a/src/Http/Validation/ValidatesRequest.php b/src/Http/Validation/ValidatesRequest.php
index 33ff76af..142bd129 100644
--- a/src/Http/Validation/ValidatesRequest.php
+++ b/src/Http/Validation/ValidatesRequest.php
@@ -17,10 +17,12 @@ trait ValidatesRequest
*/
protected function validate(Request $request, array $rules)
{
- if (!$this->validator->validate(
+ $isValid = $this->validator->validate(
(array)$request->getParsedBody(),
$rules
- )) {
+ );
+
+ if (!$isValid) {
throw new ValidationException($this->validator);
}
diff --git a/src/Middleware/LegacyMiddleware.php b/src/Middleware/LegacyMiddleware.php
index 478ffab1..f652e766 100644
--- a/src/Middleware/LegacyMiddleware.php
+++ b/src/Middleware/LegacyMiddleware.php
@@ -82,7 +82,7 @@ class LegacyMiddleware implements MiddlewareInterface
$page = 404;
$title = $translator->translate('Page not found');
- $content = $translator->translate('This page could not be found or you don\'t have permission to view it. You probably have to sign in or register in order to gain access!');
+ $content = $translator->translate('page.404.text');
}
return $this->renderPage($page, $title, $content);
@@ -103,14 +103,17 @@ class LegacyMiddleware implements MiddlewareInterface
case 'ical':
require_once realpath(__DIR__ . '/../../includes/pages/user_ical.php');
user_ical();
+ break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'atom':
require_once realpath(__DIR__ . '/../../includes/pages/user_atom.php');
user_atom();
+ break;
/** @noinspection PhpMissingBreakStatementInspection */
case 'shifts_json_export':
require_once realpath(__DIR__ . '/../../includes/controller/shifts_controller.php');
shifts_json_export_controller();
+ break;
case 'public_dashboard':
return public_dashboard_controller();
case 'angeltypes':
diff --git a/src/Models/LogEntry.php b/src/Models/LogEntry.php
index 53f72b65..8a73d305 100644
--- a/src/Models/LogEntry.php
+++ b/src/Models/LogEntry.php
@@ -24,7 +24,7 @@ class LogEntry extends BaseModel
public $timestamps = true;
/** @var null Disable updated_at */
- const UPDATED_AT = null;
+ public const UPDATED_AT = null;
/**
* The attributes that are mass assignable.
diff --git a/src/Models/User/PasswordReset.php b/src/Models/User/PasswordReset.php
index 82f44add..7f694268 100644
--- a/src/Models/User/PasswordReset.php
+++ b/src/Models/User/PasswordReset.php
@@ -18,7 +18,7 @@ class PasswordReset extends HasUserModel
public $timestamps = true;
/** @var null Disable updated_at */
- const UPDATED_AT = null;
+ public const UPDATED_AT = null;
/** The attributes that are mass assignable */
protected $fillable = [
diff --git a/src/helpers.php b/src/helpers.php
index 796b8764..de140c4e 100644
--- a/src/helpers.php
+++ b/src/helpers.php
@@ -1,5 +1,4 @@
<?php
-// Some useful functions
use Engelsystem\Application;
use Engelsystem\Config\Config;