@@ -7,8 +7,7 @@ discard block |
||
| 7 | 7 | * |
| 8 | 8 | * @package Zortje\MVC\Common\Exception |
| 9 | 9 | */ |
| 10 | -class Exception extends \Exception |
|
| 11 | -{ |
|
| 10 | +class Exception extends \Exception { |
|
| 12 | 11 | |
| 13 | 12 | /** |
| 14 | 13 | * @var string |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | * @param int $code |
| 21 | 20 | * @param null|\Exception $previous |
| 22 | 21 | */ |
| 23 | - public function __construct($message, $code = 0, \Exception $previous = null) |
|
| 24 | - { |
|
| 22 | + public function __construct($message, $code = 0, \Exception $previous = null) { |
|
| 25 | 23 | if (is_array($message)) { |
| 26 | 24 | $message = vsprintf($this->template, $message); |
| 27 | 25 | } |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @package Zortje\MVC\Controller\Exception |
| 11 | 11 | */ |
| 12 | -class ControllerActionNonexistentException extends Exception |
|
| 13 | -{ |
|
| 12 | +class ControllerActionNonexistentException extends Exception { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | /** |
| 21 | 20 | * {@inheritdoc} |
| 22 | 21 | */ |
| 23 | - public function __construct($message) |
|
| 24 | - { |
|
| 22 | + public function __construct($message) { |
|
| 25 | 23 | parent::__construct($message); |
| 26 | 24 | } |
| 27 | 25 | |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @package Zortje\MVC\Controller\Exception |
| 11 | 11 | */ |
| 12 | -class ControllerActionPrivateInsufficientAuthenticationException extends Exception |
|
| 13 | -{ |
|
| 12 | +class ControllerActionPrivateInsufficientAuthenticationException extends Exception { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | /** |
| 21 | 20 | * {@inheritdoc} |
| 22 | 21 | */ |
| 23 | - public function __construct($message) |
|
| 24 | - { |
|
| 22 | + public function __construct($message) { |
|
| 25 | 23 | parent::__construct($message); |
| 26 | 24 | } |
| 27 | 25 | |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @package Zortje\MVC\Controller\Exception |
| 11 | 11 | */ |
| 12 | -class ControllerActionProtectedInsufficientAuthenticationException extends Exception |
|
| 13 | -{ |
|
| 12 | +class ControllerActionProtectedInsufficientAuthenticationException extends Exception { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | /** |
| 21 | 20 | * {@inheritdoc} |
| 22 | 21 | */ |
| 23 | - public function __construct($message) |
|
| 24 | - { |
|
| 22 | + public function __construct($message) { |
|
| 25 | 23 | parent::__construct($message); |
| 26 | 24 | } |
| 27 | 25 | |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @package Zortje\MVC\Controller\Exception |
| 11 | 11 | */ |
| 12 | -class ControllerInvalidSuperclassException extends Exception |
|
| 13 | -{ |
|
| 12 | +class ControllerInvalidSuperclassException extends Exception { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | /** |
| 21 | 20 | * {@inheritdoc} |
| 22 | 21 | */ |
| 23 | - public function __construct($message) |
|
| 24 | - { |
|
| 22 | + public function __construct($message) { |
|
| 25 | 23 | parent::__construct($message); |
| 26 | 24 | } |
| 27 | 25 | |
@@ -9,8 +9,7 @@ discard block |
||
| 9 | 9 | * |
| 10 | 10 | * @package Zortje\MVC\Controller\Exception |
| 11 | 11 | */ |
| 12 | -class ControllerNonexistentException extends Exception |
|
| 13 | -{ |
|
| 12 | +class ControllerNonexistentException extends Exception { |
|
| 14 | 13 | |
| 15 | 14 | /** |
| 16 | 15 | * {@inheritdoc} |
@@ -20,8 +19,7 @@ discard block |
||
| 20 | 19 | /** |
| 21 | 20 | * {@inheritdoc} |
| 22 | 21 | */ |
| 23 | - public function __construct($message) |
|
| 24 | - { |
|
| 22 | + public function __construct($message) { |
|
| 25 | 23 | parent::__construct($message); |
| 26 | 24 | } |
| 27 | 25 | |
@@ -13,8 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @package Zortje\MVC\Controller |
| 15 | 15 | */ |
| 16 | -class Controller |
|
| 17 | -{ |
|
| 16 | +class Controller { |
|
| 18 | 17 | |
| 19 | 18 | /** |
| 20 | 19 | * Controller action is publicly accessible |
@@ -92,8 +91,7 @@ discard block |
||
| 92 | 91 | /** |
| 93 | 92 | * @return string Controller name without namespace |
| 94 | 93 | */ |
| 95 | - public function getShortName() |
|
| 96 | - { |
|
| 94 | + public function getShortName() { |
|
| 97 | 95 | return str_replace('Controller', null, (new \ReflectionClass($this))->getShortName()); |
| 98 | 96 | } |
| 99 | 97 | |
@@ -104,8 +102,7 @@ discard block |
||
| 104 | 102 | * @throws ControllerActionPrivateInsufficientAuthenticationException |
| 105 | 103 | * @throws ControllerActionProtectedInsufficientAuthenticationException |
| 106 | 104 | */ |
| 107 | - public function setAction($action) |
|
| 108 | - { |
|
| 105 | + public function setAction($action) { |
|
| 109 | 106 | /** |
| 110 | 107 | * Check if method exists and that access has been defined |
| 111 | 108 | */ |
@@ -137,8 +134,7 @@ discard block |
||
| 137 | 134 | * |
| 138 | 135 | * @throws \LogicException If controller action is not set |
| 139 | 136 | */ |
| 140 | - public function callAction() |
|
| 141 | - { |
|
| 137 | + public function callAction() { |
|
| 142 | 138 | if (!isset($this->action)) { |
| 143 | 139 | throw new \LogicException('Controller action must be set before being called'); |
| 144 | 140 | } |
@@ -182,8 +178,7 @@ discard block |
||
| 182 | 178 | * |
| 183 | 179 | * Called right before controller action is called |
| 184 | 180 | */ |
| 185 | - protected function beforeAction() |
|
| 186 | - { |
|
| 181 | + protected function beforeAction() { |
|
| 187 | 182 | /** |
| 188 | 183 | * Set New Relic transaction name |
| 189 | 184 | */ |
@@ -197,8 +192,7 @@ discard block |
||
| 197 | 192 | * |
| 198 | 193 | * Called right after controller action is called, but before rendering of the view |
| 199 | 194 | */ |
| 200 | - protected function afterAction() |
|
| 201 | - { |
|
| 195 | + protected function afterAction() { |
|
| 202 | 196 | } |
| 203 | 197 | |
| 204 | 198 | /** |
@@ -207,8 +201,7 @@ discard block |
||
| 207 | 201 | * @param string $variable |
| 208 | 202 | * @param mixed $value |
| 209 | 203 | */ |
| 210 | - protected function set($variable, $value) |
|
| 211 | - { |
|
| 204 | + protected function set($variable, $value) { |
|
| 212 | 205 | $this->variables[$variable] = $value; |
| 213 | 206 | } |
| 214 | 207 | |
@@ -217,8 +210,7 @@ discard block |
||
| 217 | 210 | * |
| 218 | 211 | * @return string Layout template file path |
| 219 | 212 | */ |
| 220 | - protected function getLayoutTemplate() |
|
| 221 | - { |
|
| 213 | + protected function getLayoutTemplate() { |
|
| 222 | 214 | $layout = $this->layout; |
| 223 | 215 | |
| 224 | 216 | if (empty($layout)) { |
@@ -233,8 +225,7 @@ discard block |
||
| 233 | 225 | * |
| 234 | 226 | * @return string View template file path |
| 235 | 227 | */ |
| 236 | - protected function getViewTemplate() |
|
| 237 | - { |
|
| 228 | + protected function getViewTemplate() { |
|
| 238 | 229 | $view = $this->view; |
| 239 | 230 | |
| 240 | 231 | if (empty($view)) { |
@@ -253,8 +244,7 @@ discard block |
||
| 253 | 244 | * |
| 254 | 245 | * @throws \InvalidArgumentException If unsupported code is provided |
| 255 | 246 | */ |
| 256 | - protected function setResponseCode($code) |
|
| 257 | - { |
|
| 247 | + protected function setResponseCode($code) { |
|
| 258 | 248 | switch ($code) { |
| 259 | 249 | case 200: |
| 260 | 250 | $text = 'OK'; |
@@ -289,8 +279,7 @@ discard block |
||
| 289 | 279 | * @param string $appPath |
| 290 | 280 | * @param null|User $user |
| 291 | 281 | */ |
| 292 | - public function __construct(\PDO $pdo, $appPath, User $user = null) |
|
| 293 | - { |
|
| 282 | + public function __construct(\PDO $pdo, $appPath, User $user = null) { |
|
| 294 | 283 | $this->pdo = $pdo; |
| 295 | 284 | $this->appPath = $appPath; |
| 296 | 285 | $this->user = $user; |
@@ -11,8 +11,7 @@ discard block |
||
| 11 | 11 | * |
| 12 | 12 | * @package Zortje\MVC\Controller |
| 13 | 13 | */ |
| 14 | -class ControllerFactory |
|
| 15 | -{ |
|
| 14 | +class ControllerFactory { |
|
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * @var \PDO PDO |
@@ -39,8 +38,7 @@ discard block |
||
| 39 | 38 | * @throws ControllerInvalidSuperclassException |
| 40 | 39 | * @throws ControllerNonexistentException |
| 41 | 40 | */ |
| 42 | - public function create($controller) |
|
| 43 | - { |
|
| 41 | + public function create($controller) { |
|
| 44 | 42 | if (!class_exists($controller)) { |
| 45 | 43 | throw new ControllerNonexistentException([$controller]); |
| 46 | 44 | } elseif (!is_subclass_of($controller, Controller::class)) { |
@@ -60,8 +58,7 @@ discard block |
||
| 60 | 58 | * @param string $appPath |
| 61 | 59 | * @param null|User $user |
| 62 | 60 | */ |
| 63 | - public function __construct(\PDO $pdo, $appPath, User $user = null) |
|
| 64 | - { |
|
| 61 | + public function __construct(\PDO $pdo, $appPath, User $user = null) { |
|
| 65 | 62 | $this->pdo = $pdo; |
| 66 | 63 | $this->appPath = $appPath; |
| 67 | 64 | $this->user = $user; |
@@ -7,15 +7,13 @@ |
||
| 7 | 7 | * |
| 8 | 8 | * @package Zortje\MVC\Controller |
| 9 | 9 | */ |
| 10 | -class NotFoundController extends Controller |
|
| 11 | -{ |
|
| 10 | +class NotFoundController extends Controller { |
|
| 12 | 11 | |
| 13 | 12 | protected $access = [ |
| 14 | 13 | 'index' => Controller::ACTION_PUBLIC |
| 15 | 14 | ]; |
| 16 | 15 | |
| 17 | - protected function index() |
|
| 18 | - { |
|
| 16 | + protected function index() { |
|
| 19 | 17 | $this->setResponseCode(404); |
| 20 | 18 | } |
| 21 | 19 | } |