@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $statement->bindParam(':id', $noteId); |
| 21 | 21 | $statement->execute(); |
| 22 | 22 | $note = $statement->fetchObject(); |
| 23 | - if (! $note) { |
|
| 23 | + if (!$note) { |
|
| 24 | 24 | throw new Note('Note not found.', 404); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $statement->bindParam('description', $description); |
| 47 | 47 | $statement->execute(); |
| 48 | 48 | $notes = $statement->fetchAll(); |
| 49 | - if (! $notes) { |
|
| 49 | + if (!$notes) { |
|
| 50 | 50 | throw new Note('No notes with that name or description were found.', 404); |
| 51 | 51 | } |
| 52 | 52 | |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $statement->bindParam('userId', $userId); |
| 22 | 22 | $statement->execute(); |
| 23 | 23 | $task = $statement->fetchObject(); |
| 24 | - if (! $task) { |
|
| 24 | + if (!$task) { |
|
| 25 | 25 | throw new Task('Task not found.', 404); |
| 26 | 26 | } |
| 27 | 27 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | $statement->bindParam('id', $userId); |
| 21 | 21 | $statement->execute(); |
| 22 | 22 | $user = $statement->fetchObject(); |
| 23 | - if (! $user) { |
|
| 23 | + if (!$user) { |
|
| 24 | 24 | throw new User('User not found.', 404); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | $statement->bindParam('name', $name); |
| 57 | 57 | $statement->execute(); |
| 58 | 58 | $users = $statement->fetchAll(); |
| 59 | - if (! $users) { |
|
| 59 | + if (!$users) { |
|
| 60 | 60 | throw new User('User name not found.', 404); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | $statement->bindParam('password', $password); |
| 72 | 72 | $statement->execute(); |
| 73 | 73 | $user = $statement->fetchObject(); |
| 74 | - if (! $user) { |
|
| 74 | + if (!$user) { |
|
| 75 | 75 | throw new User('Login failed: Email or password incorrect.', 400); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -8,8 +8,8 @@ discard block |
||
| 8 | 8 | $app->get('/status', 'App\Controller\DefaultController:getStatus'); |
| 9 | 9 | $app->post('/login', \App\Controller\User\Login::class); |
| 10 | 10 | |
| 11 | -$app->group('/api/v1', function () use ($app): void { |
|
| 12 | - $app->group('/tasks', function () use ($app): void { |
|
| 11 | +$app->group('/api/v1', function() use ($app): void { |
|
| 12 | + $app->group('/tasks', function() use ($app): void { |
|
| 13 | 13 | $app->get('', \App\Controller\Task\GetAll::class); |
| 14 | 14 | $app->get('/[{id}]', \App\Controller\Task\GetOne::class); |
| 15 | 15 | $app->get('/search/[{query}]', \App\Controller\Task\Search::class); |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | $app->delete('/[{id}]', \App\Controller\Task\Delete::class); |
| 19 | 19 | })->add(new Auth()); |
| 20 | 20 | |
| 21 | - $app->group('/users', function () use ($app): void { |
|
| 21 | + $app->group('/users', function() use ($app): void { |
|
| 22 | 22 | $app->get('', \App\Controller\User\GetAll::class)->add(new Auth()); |
| 23 | 23 | $app->get('/[{id}]', \App\Controller\User\GetOne::class)->add(new Auth()); |
| 24 | 24 | $app->get('/search/[{query}]', \App\Controller\User\Search::class)->add(new Auth()); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | $app->delete('/[{id}]', \App\Controller\User\Delete::class)->add(new Auth()); |
| 28 | 28 | }); |
| 29 | 29 | |
| 30 | - $app->group('/notes', function () use ($app): void { |
|
| 30 | + $app->group('/notes', function() use ($app): void { |
|
| 31 | 31 | $app->get('', \App\Controller\Note\GetAll::class); |
| 32 | 32 | $app->get('/[{id}]', \App\Controller\Note\GetOne::class); |
| 33 | 33 | $app->get('/search/[{query}]', \App\Controller\Note\Search::class); |
@@ -9,14 +9,14 @@ |
||
| 9 | 9 | |
| 10 | 10 | $container = $app->getContainer(); |
| 11 | 11 | |
| 12 | -$container['user_repository'] = static function (ContainerInterface $container): UserRepository { |
|
| 12 | +$container['user_repository'] = static function(ContainerInterface $container): UserRepository { |
|
| 13 | 13 | return new UserRepository($container->get('db')); |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | -$container['task_repository'] = static function (ContainerInterface $container): TaskRepository { |
|
| 16 | +$container['task_repository'] = static function(ContainerInterface $container): TaskRepository { |
|
| 17 | 17 | return new TaskRepository($container->get('db')); |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | -$container['note_repository'] = static function (ContainerInterface $container): NoteRepository { |
|
| 20 | +$container['note_repository'] = static function(ContainerInterface $container): NoteRepository { |
|
| 21 | 21 | return new NoteRepository($container->get('db')); |
| 22 | 22 | }; |
@@ -9,8 +9,8 @@ |
||
| 9 | 9 | |
| 10 | 10 | $container = $app->getContainer(); |
| 11 | 11 | |
| 12 | -$container['user_service'] = static fn (ContainerInterface $container): UserService => new UserService($container->get('user_repository'), $container->get('redis_service')); |
|
| 12 | +$container['user_service'] = static fn(ContainerInterface $container): UserService => new UserService($container->get('user_repository'), $container->get('redis_service')); |
|
| 13 | 13 | |
| 14 | -$container['task_service'] = static fn (ContainerInterface $container): TaskService => new TaskService($container->get('task_repository'), $container->get('redis_service')); |
|
| 14 | +$container['task_service'] = static fn(ContainerInterface $container): TaskService => new TaskService($container->get('task_repository'), $container->get('redis_service')); |
|
| 15 | 15 | |
| 16 | -$container['note_service'] = static fn (ContainerInterface $container): NoteService => new NoteService($container->get('note_repository'), $container->get('redis_service')); |
|
| 16 | +$container['note_service'] = static fn(ContainerInterface $container): NoteService => new NoteService($container->get('note_repository'), $container->get('redis_service')); |
|
@@ -8,7 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | $container = $app->getContainer(); |
| 10 | 10 | |
| 11 | -$container['db'] = static function (ContainerInterface $c): PDO { |
|
| 11 | +$container['db'] = static function(ContainerInterface $c): PDO { |
|
| 12 | 12 | $db = $c->get('settings')['db']; |
| 13 | 13 | $pdo = new PDO( |
| 14 | 14 | sprintf('mysql:host=%s;dbname=%s', $db['hostname'], $db['database']), |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | return $pdo; |
| 23 | 23 | }; |
| 24 | 24 | |
| 25 | -$container['errorHandler'] = static fn (): ApiError => new ApiError(); |
|
| 25 | +$container['errorHandler'] = static fn(): ApiError => new ApiError(); |
|
| 26 | 26 | |
| 27 | -$container['redis_service'] = static function (): RedisService { |
|
| 27 | +$container['redis_service'] = static function(): RedisService { |
|
| 28 | 28 | return new RedisService(new \Predis\Client(getenv('REDIS_URL'))); |
| 29 | 29 | }; |
@@ -13,11 +13,11 @@ |
||
| 13 | 13 | public function __invoke(Request $request, Response $response, $next): ResponseInterface |
| 14 | 14 | { |
| 15 | 15 | $jwtHeader = $request->getHeaderLine('Authorization'); |
| 16 | - if (! $jwtHeader) { |
|
| 16 | + if (!$jwtHeader) { |
|
| 17 | 17 | throw new \App\Exception\Auth('JWT Token required.', 400); |
| 18 | 18 | } |
| 19 | 19 | $jwt = explode('Bearer ', $jwtHeader); |
| 20 | - if (! isset($jwt[1])) { |
|
| 20 | + if (!isset($jwt[1])) { |
|
| 21 | 21 | throw new \App\Exception\Auth('JWT Token invalid.', 400); |
| 22 | 22 | } |
| 23 | 23 | $decoded = $this->checkToken($jwt[1]); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | protected static function validateUserName(string $name): string |
| 28 | 28 | { |
| 29 | - if (! v::alnum()->length(2, 100)->validate($name)) { |
|
| 29 | + if (!v::alnum()->length(2, 100)->validate($name)) { |
|
| 30 | 30 | throw new User('Invalid name.', 400); |
| 31 | 31 | } |
| 32 | 32 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | protected static function validateEmail(string $emailValue): string |
| 37 | 37 | { |
| 38 | 38 | $email = filter_var($emailValue, FILTER_SANITIZE_EMAIL); |
| 39 | - if (! v::email()->validate($email)) { |
|
| 39 | + if (!v::email()->validate($email)) { |
|
| 40 | 40 | throw new User('Invalid email', 400); |
| 41 | 41 | } |
| 42 | 42 | |