Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
maurobonfietti committed Jul 31, 2020
1 parent bb77bfd commit b392a35
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
7 changes: 5 additions & 2 deletions src/Controller/Note/Delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

final class Delete extends Base
{
public function __invoke(Request $request, Response $response, array $args): Response
{
public function __invoke(
Request $request,
Response $response,
array $args
): Response {
$this->getServiceDeleteNote()->delete((int) $args['id']);

return $this->jsonResponse($response, 'success', null, 204);
Expand Down
7 changes: 5 additions & 2 deletions src/Controller/Note/GetAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

final class GetAll extends Base
{
public function __invoke(Request $request, Response $response): Response
{
public function __invoke(
Request $request,
Response $response,
array $args
): Response {
$page = $request->getQueryParam('page', null);
$perPage = $request->getQueryParam('perPage', self::DEFAULT_PER_PAGE_PAGINATION);

Expand Down
7 changes: 5 additions & 2 deletions src/Controller/Note/GetOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

final class GetOne extends Base
{
public function __invoke(Request $request, Response $response, array $args): Response
{
public function __invoke(
Request $request,
Response $response,
array $args
): Response {
$note = $this->getServiceFindNote()->getOne((int) $args['id']);

return $this->jsonResponse($response, 'success', $note, 200);
Expand Down
7 changes: 5 additions & 2 deletions src/Controller/Note/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

final class Search extends Base
{
public function __invoke(Request $request, Response $response, array $args): Response
{
public function __invoke(
Request $request,
Response $response,
array $args
): Response {
$notes = $this->getServiceFindNote()->search($args['query']);

return $this->jsonResponse($response, 'success', $notes, 200);
Expand Down
7 changes: 5 additions & 2 deletions src/Controller/Note/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@

final class Update extends Base
{
public function __invoke(Request $request, Response $response, array $args): Response
{
public function __invoke(
Request $request,
Response $response,
array $args
): Response {
$input = (array) $request->getParsedBody();
$note = $this->getServiceUpdateNote()->update($input, (int) $args['id']);

Expand Down
2 changes: 1 addition & 1 deletion src/Repository/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected function getDb(): \PDO
protected function getResultByPage($query, $page, $perPage)
{
$offset = ($page - 1) * $perPage;
$query = $query . " LIMIT ${perPage} OFFSET ${offset}";
$query .= " LIMIT ${perPage} OFFSET ${offset}";
$statement = $this->database->prepare($query);
$statement->execute();

Expand Down

0 comments on commit b392a35

Please sign in to comment.