Commit 49400a05 authored by Jacob Priddy's avatar Jacob Priddy 👌

Fix code styles

parent 0c9f7a86
......@@ -4,14 +4,14 @@ namespace App\Http\Controllers\Api;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\GroupSchedule\GetGroupSchedules\ApiPresenter as GroupSchedulesApiPresenter;
use Source\UseCases\GroupSchedule\GetGroupSchedules\GetGroupSchedulesUseCase;
use Source\UseCases\GroupSchedule\GetScheduleGroups\ApiPresenter as ScheduleGroupsApiPresenter;
use Source\UseCases\GroupSchedule\GetScheduleGroups\GetScheduleGroupsUseCase;
use Source\UseCases\GroupSchedule\RemoveSchedulesFromGroups\ApiPresenter as DetachSchedulesFromGroupsApiPresenter;
use Source\UseCases\GroupSchedule\AddSchedulesToGroups\AddSchedulesToGroupsUseCase;
use Source\UseCases\GroupSchedule\RemoveSchedulesFromGroups\RemoveSchedulesFromGroupsUseCase;
use Source\UseCases\GroupSchedule\GetGroupSchedules\ApiPresenter as GroupSchedulesApiPresenter;
use Source\UseCases\GroupSchedule\GetScheduleGroups\ApiPresenter as ScheduleGroupsApiPresenter;
use Source\UseCases\GroupSchedule\AddSchedulesToGroups\ApiPresenter as GroupScheduleAttachApiPresenter;
use Source\UseCases\GroupSchedule\AddSchedulesToGroups\AddSchedulesToGroupsUseCase;
use Source\UseCases\GroupSchedule\RemoveSchedulesFromGroups\ApiPresenter as DetachSchedulesFromGroupsApiPresenter;
/**
* @group Group Schedule Mapping
......
......@@ -9,8 +9,6 @@ use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Door\ScheduleEvents\ScheduleEvents;
use Source\UseCases\Users\UpdateUser\UpdateCurrentUser;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Requests\InteractWithRequest\InteractWithRequestUseCase;
use Source\UseCases\Requests\DeleteRequest\ApiPresenter as DeleteRequestApiPresenter;
use Source\UseCases\Requests\GetRequests\GetRequestsUseCase;
use Source\UseCases\Requests\CreateRequest\CreateRequestUseCase;
use Source\UseCases\Requests\DeleteRequest\DeleteRequestUseCase;
......@@ -19,9 +17,11 @@ use Source\UseCases\Requests\ApiPresenter as RequestApiPresenter;
use Source\UseCases\DoorUser\UserDoorAccess\UserDoorAccessUseCase;
use Source\UseCases\Users\GetUser\APIPresenter as GetUserAPIPresenter;
use Source\UseCases\Tokens\GetTokens\APIPresenter as GetTokensApiPresenter;
use Source\UseCases\Requests\InteractWithRequest\InteractWithRequestUseCase;
use Source\UseCases\Users\UpdateUser\APIPresenter as UpdateUserAPIPresenter;
use Source\UseCases\Requests\GetRequests\ApiPresenter as RequestsApiPresenter;
use Source\UseCases\DoorUser\UserDoorAccess\MePresenter as DoorUserMePresenter;
use Source\UseCases\Requests\DeleteRequest\ApiPresenter as DeleteRequestApiPresenter;
use Source\UseCases\GroupUser\GetUserGroups\APIPresenter as GetUserGroupsAPIPresenter;
/**
......
......@@ -6,15 +6,15 @@ use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Schedules\ScheduleDelete\ApiPresenter as ScheduleDeleteApiPresenter;
use Source\UseCases\Schedules\ScheduleGet\ScheduleGetUseCase;
use Source\UseCases\Door\ScheduleEvents\ScheduleEventsUseCase;
use Source\UseCases\Schedules\SchedulesGet\SchedulesGetUseCase;
use Source\UseCases\Schedules\APIPresenter as ScheduleApiPresenter;
use Source\UseCases\Schedules\ScheduleCreate\ScheduleCreateUseCase;
use Source\UseCases\Schedules\ScheduleUpdate\ScheduleUpdateUseCase;
use Source\UseCases\Schedules\ScheduleDelete\ScheduleDeleteUseCase;
use Source\UseCases\Schedules\ScheduleUpdate\ScheduleUpdateUseCase;
use Source\UseCases\Schedules\SchedulesGet\APIPresenter as SchedulesGetApiPresenter;
use Source\UseCases\Schedules\ScheduleDelete\ApiPresenter as ScheduleDeleteApiPresenter;
/**
* @group Schedules Management
......
......@@ -3,22 +3,21 @@
namespace App\Http\Controllers\Web\Admin;
use Illuminate\View\View;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Source\UseCases\Doors\GetDoor\GetDoorUseCase;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Doors\CreateDoor\CreateDoorUseCase;
use Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCase;
use Source\UseCases\Doors\DeleteDoor\DeleteDoorUseCase;
use Source\UseCases\Doors\UpdateDoor\UpdateDoorUseCase;
use Source\UseCases\Doors\CreateDoor\WebTokenGeneratePresenter;
use Source\UseCases\Doors\GetDoor\APIPresenter as GetDoorPresenter;
use Source\UseCases\Doors\GetDoors\WebPresenter as GetDoorsPresenter;
use Source\UseCases\Doors\GenerateDoorToken\GenerateDoorTokenUseCase;
use Source\UseCases\Doors\GetDoors\WebPresenter as GetDoorsPresenter;
use Source\UseCases\Doors\CreateDoor\WebPresenter as CreateDoorPresenter;
use Source\UseCases\Doors\UpdateDoor\APIPresenter as UpdateDoorPresenter;
use Source\UseCases\Doors\DeleteDoor\APIPresenter as DeleteDoorPresenter;
use Source\UseCases\Doors\UpdateDoor\APIPresenter as UpdateDoorPresenter;
class DoorsController extends Controller
{
......
......@@ -3,23 +3,22 @@
namespace App\Http\Controllers\Web\Admin;
use Illuminate\View\View;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Source\Exceptions\EntityExistsException;
use Source\Exceptions\DeleteFailedException;
use Source\Exceptions\EntityExistsException;
use Illuminate\Validation\ValidationException;
use Source\UseCases\Groups\UpdateGroup\WebPresenter as UpdateGroupPresenter;
use Source\UseCases\Groups\UpdateGroup\UpdateGroupUseCase;
use Source\UseCases\Groups\GetGroup\APIPresenter as GetGroupPresenter;
use Source\UseCases\Groups\GetGroup\GetGroupUseCase;
use Source\UseCases\Groups\CreateGroup\WebPresenter as CreateGroupPresenter;
use Source\UseCases\Groups\GetGroups\GetGroupsUseCase;
use Source\UseCases\Groups\CreateGroup\CreateGroupUseCase;
use Source\UseCases\Groups\DeleteGroup\APIPresenter as DeleteGroupPresenter;
use Source\UseCases\Groups\DeleteGroup\DeleteGroupUseCase;
use Source\UseCases\Groups\UpdateGroup\UpdateGroupUseCase;
use Source\UseCases\Groups\GetGroups\WebPresenter as GroupsPresenter;
use Source\UseCases\Groups\GetGroups\GetGroupsUseCase;
use Source\UseCases\Groups\GetGroup\APIPresenter as GetGroupPresenter;
use Source\UseCases\Groups\CreateGroup\WebPresenter as CreateGroupPresenter;
use Source\UseCases\Groups\DeleteGroup\APIPresenter as DeleteGroupPresenter;
use Source\UseCases\Groups\UpdateGroup\WebPresenter as UpdateGroupPresenter;
class GroupsController extends Controller
{
......
......@@ -7,16 +7,16 @@ use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Source\Exceptions\DeleteFailedException;
use Source\Exceptions\AuthorizationException;
use Source\UseCases\Users\UpdateUser\UpdateUserUseCase;
use Source\UseCases\Users\GetUser\GetUserUseCase;
use Source\UseCases\Users\GetUsers\GetUsersUseCase;
use Source\UseCases\Users\CreateUser\CreateUserUseCase;
use Source\UseCases\Users\DeleteUser\DeleteUserUseCase;
use Source\UseCases\Users\UpdateUser\UpdateUserUseCase;
use Source\UseCases\Users\GetUser\WebPresenter as GetUserPresenter;
use Source\UseCases\Users\GetUsers\WebPresenter as GetUsersPresenter;
use Source\UseCases\Users\GetUser\GetUserUseCase;
use Source\UseCases\Users\CreateUser\WebPresenter as CreateUserPresenter;
use Source\UseCases\Users\DeleteUser\APIPresenter as DeleteUserPresenter;
use Source\UseCases\Users\GetUsers\GetUsersUseCase;
use Source\UseCases\Users\DeleteUser\DeleteUserUseCase;
use Source\UseCases\Users\UpdateUser\WebPresenter as UpdateUserPresenter;
use Source\UseCases\Users\CreateUser\WebPresenter as CreateUserPresenter;
class UsersController extends Controller
{
......
......@@ -14,11 +14,11 @@ use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Users\UpdateUser\UpdateCurrentUser;
use Source\UseCases\Requests\GetRequest\GetRequestUseCase;
use Source\UseCases\Requests\GetRequests\GetRequestsUseCase;
use Source\UseCases\Requests\DeleteRequest\DeleteRequestUseCase;
use Source\UseCases\Requests\CreateRequest\CreateRequestUseCase;
use Source\UseCases\Requests\DeleteRequest\DeleteRequestUseCase;
use Source\UseCases\Tokens\GetTokens\WebPresenter as GetTokensWebPresenter;
use Source\UseCases\Users\UpdateUser\WebPresenter as UpdateUserWebPresenter;
use Source\UseCases\Requests\InteractWithRequest\InteractWithRequestUseCase;
use Source\UseCases\Users\UpdateUser\WebPresenter as UpdateUserWebPresenter;
use Source\UseCases\Requests\GetRequests\WebPresenter as RequestsWebPresenter;
use Source\UseCases\Requests\DeleteRequest\WebPresenter as DeleteRequestWebPresenter;
......
......@@ -5,8 +5,8 @@ use Source\Authorization\Permissions;
use App\Http\Controllers\Web\MeController;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Web\Admin\HomeController;
use App\Http\Controllers\Web\Admin\LoginController;
use App\Http\Controllers\Web\Admin\DoorsController;
use App\Http\Controllers\Web\Admin\LoginController;
use App\Http\Controllers\Web\Admin\UsersController;
use App\Http\Controllers\Web\Admin\GroupsController;
......
......@@ -33,7 +33,7 @@ class InMemoryDoorScheduleRepository implements DoorScheduleRepository
$now = Carbon::now();
return array_filter($this->doorScheduleMap[$doorId], fn(Schedule $schedule): bool => $schedule->isActiveForDate($now));
return array_filter($this->doorScheduleMap[$doorId], fn (Schedule $schedule): bool => $schedule->isActiveForDate($now));
}
/**
......@@ -45,7 +45,7 @@ class InMemoryDoorScheduleRepository implements DoorScheduleRepository
return [];
}
return array_filter($this->doorScheduleMap[$doorId], fn(Schedule $schedule): bool => $schedule->hasTypeOf($type) && $schedule->overlaps($begin, $end));
return array_filter($this->doorScheduleMap[$doorId], fn (Schedule $schedule): bool => $schedule->hasTypeOf($type) && $schedule->overlaps($begin, $end));
}
/**
......@@ -57,6 +57,6 @@ class InMemoryDoorScheduleRepository implements DoorScheduleRepository
return [];
}
return array_filter($this->doorScheduleMap[$doorId], fn(Schedule $schedule): bool => $schedule->overlaps($begin, $end) && $schedule->hasTypeOf(Schedule::TYPE_USER_ACCESS));
return array_filter($this->doorScheduleMap[$doorId], fn (Schedule $schedule): bool => $schedule->overlaps($begin, $end) && $schedule->hasTypeOf(Schedule::TYPE_USER_ACCESS));
}
}
......@@ -145,7 +145,7 @@ class DatabaseDoorsRepository implements DoorsRepository
});
}
return array_map(fn(\App\Door $door): Door => self::makeDoorFromDb($door), $doors->get()->values()->all());
return array_map(fn (\App\Door $door): Door => self::makeDoorFromDb($door), $doors->get()->values()->all());
}
/**
......
......@@ -43,7 +43,7 @@ class DatabaseGroupScheduleRepository implements GroupScheduleRepository
}
return array_map(
fn(Group $group) => DatabaseGroupsRepository::makeGroupFromDbGroup($group),
fn (Group $group) => DatabaseGroupsRepository::makeGroupFromDbGroup($group),
$schedule->groups()->get()->all()
);
}
......@@ -61,7 +61,7 @@ class DatabaseGroupScheduleRepository implements GroupScheduleRepository
}
return array_map(
fn(Schedule $schedule) => DatabaseSchedulesRepository::toSchedule($schedule),
fn (Schedule $schedule) => DatabaseSchedulesRepository::toSchedule($schedule),
$group->schedules()->get()->all()
);
}
......@@ -71,7 +71,7 @@ class DatabaseGroupScheduleRepository implements GroupScheduleRepository
*/
public function addSchedulesToGroups(array $scheduleIds, array $groupIds): void
{
$groups = Group::query()->findMany(array_map(fn(string $id) => self::castToInt($id), $groupIds))->values()->all();
$groups = Group::query()->findMany(array_map(fn (string $id) => self::castToInt($id), $groupIds))->values()->all();
/** @var Group $group */
foreach ($groups as $group) {
......@@ -94,7 +94,7 @@ class DatabaseGroupScheduleRepository implements GroupScheduleRepository
*/
public function removeSchedulesFromGroups(array $scheduleIds, array $groupIds): void
{
$groups = Group::query()->findMany(array_map(fn(string $id) => self::castToInt($id), $groupIds))->values()->all();
$groups = Group::query()->findMany(array_map(fn (string $id) => self::castToInt($id), $groupIds))->values()->all();
/** @var Group $group */
foreach ($groups as $group) {
......@@ -125,6 +125,6 @@ QUERY;
$schedules = $this->db->select($query, $bind);
return array_map(fn($schedule): \Source\Entities\Schedule => DatabaseDoorScheduleRepository::createScheduleFromObject($schedule), $schedules);
return array_map(fn ($schedule): \Source\Entities\Schedule => DatabaseDoorScheduleRepository::createScheduleFromObject($schedule), $schedules);
}
}
......@@ -28,7 +28,7 @@ class InMemoryRequestsRepository implements RequestsRepository
*/
public function pending(): array
{
return array_filter($this->requests, fn(Request $request) => !$request->isResolved());
return array_filter($this->requests, fn (Request $request) => !$request->isResolved());
}
/**
......@@ -61,18 +61,18 @@ class InMemoryRequestsRepository implements RequestsRepository
}
if ($userId !== null) {
$requests = array_filter($requests, fn(Request $request): bool => $request->hasUserIdOf($userId));
$requests = array_filter($requests, fn (Request $request): bool => $request->hasUserIdOf($userId));
}
if ($resolved !== null) {
$requests = array_filter($requests, fn(Request $request): bool => $request->isResolved() === $resolved);
$requests = array_filter($requests, fn (Request $request): bool => $request->isResolved() === $resolved);
}
if ($replied !== null) {
if ($replied) {
$requests = array_filter($requests, fn(Request $request): bool => $request->getReply() !== null);
$requests = array_filter($requests, fn (Request $request): bool => $request->getReply() !== null);
} else {
$requests = array_filter($requests, fn(Request $request): bool => $request->getReply() === null);
$requests = array_filter($requests, fn (Request $request): bool => $request->getReply() === null);
}
}
......@@ -103,7 +103,7 @@ class InMemoryRequestsRepository implements RequestsRepository
public function delete(array $requestIds): int
{
$countBefore = count($this->requests);
$this->requests = array_filter($this->requests, fn(Request $request): bool => !in_array($request->getId(), $requestIds, false));
$this->requests = array_filter($this->requests, fn (Request $request): bool => !in_array($request->getId(), $requestIds, false));
return $countBefore - count($this->requests);
}
}
......@@ -91,6 +91,5 @@ class LocalRequestsRepository extends InMemoryRequestsRepository
$now,
$now
));
}
}
......@@ -55,19 +55,19 @@ class InMemorySchedulesRepository implements SchedulesRepository
$include = $include &&
($begin->lessThanOrEqualTo($schedule->getEnd()) &&
$end->greaterThanOrEqualTo($schedule->getStart()));
} else if ($begin) {
} elseif ($begin) {
$include = $include && $begin->lessThanOrEqualTo($schedule->getEnd());
} else if ($end) {
} elseif ($end) {
$include = $include && $end->greaterThanOrEqualTo($schedule->getStart());
}
} else if ($begin && $end) {
} elseif ($begin && $end) {
$include = $include &&
(($begin->lessThanOrEqualTo($schedule->getStart()) &&
$end->greaterThanOrEqualTo($schedule->getStart())) ||
$begin->greaterThanOrEqualTo($schedule->getStart()));
} else if ($begin) {
} elseif ($begin) {
$include = $include && $begin->greaterThanOrEqualTo($schedule->getStart());
} else if ($end) {
} elseif ($end) {
$include = $include && $end->greaterThanOrEqualTo($schedule->getStart());
}
......@@ -96,11 +96,11 @@ class InMemorySchedulesRepository implements SchedulesRepository
*/
public function delete(array $scheduleIds): int
{
$scheduleIds = array_map(fn($id): int => (int)$id, $scheduleIds);
$scheduleIds = array_map(fn ($id): int => (int)$id, $scheduleIds);
$countBefore = count($this->schedules);
$this->schedules = array_filter(
$this->schedules,
fn(Schedule $schedule): bool => !in_array($schedule->getId(), $scheduleIds, false)
fn (Schedule $schedule): bool => !in_array($schedule->getId(), $scheduleIds, false)
);
return $countBefore - count($this->schedules);
......
......@@ -68,7 +68,7 @@ class Statistics implements StatisticsUseCase
$response->setActiveUsers($this->statistics->countActiveUsers($start, $date));
$response->setDoorCount(count($this->doors->search(null,Door::AWOL_TIME_SECONDS)));
$response->setDoorCount(count($this->doors->search(null, Door::AWOL_TIME_SECONDS)));
$response->setMissingDoors(count($this->doors->search(null, null, Door::AWOL_TIME_SECONDS)));
......
......@@ -110,7 +110,7 @@ class ScheduleEvents implements ScheduleEventsUseCase
if ($schedule->hasTypeOf(Schedule::TYPE_OPEN_MODE)) {
$response->addOpenEvent($scheduleEvent);
} else if ($schedule->hasTypeOf(Schedule::TYPE_USER_ACCESS)) {
} elseif ($schedule->hasTypeOf(Schedule::TYPE_USER_ACCESS)) {
$response->addUserEvent($scheduleEvent);
}
}
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\GroupSchedule\AddSchedulesToGroups;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -12,7 +12,7 @@ class ApiPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->viewModel['schedules'] = array_map(fn(Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
$this->viewModel['schedules'] = array_map(fn (Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
}
/** @inheritDoc */
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\GroupSchedule\GetGroupSchedules;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -12,7 +12,7 @@ class ApiPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->viewModel['groups'] = array_map(fn(Group $group): array => self::formatGroup($group), $responseModel->getGroups());
$this->viewModel['groups'] = array_map(fn (Group $group): array => self::formatGroup($group), $responseModel->getGroups());
}
/** @inheritDoc */
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\GroupSchedule\GetScheduleGroups;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\GroupSchedule\RemoveSchedulesFromGroups;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -15,7 +15,7 @@ class WebPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->groups = array_map(fn(Group $group): array => self::formatGroup($group), $responseModel->getGroups());
$this->groups = array_map(fn (Group $group): array => self::formatGroup($group), $responseModel->getGroups());
}
/** @inheritDoc */
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\Requests\DeleteRequest;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -3,9 +3,9 @@
namespace Source\UseCases\Schedules\ScheduleDelete;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -15,7 +15,7 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->users = array_map(fn(User $user): array => self::formatPartialUser($user), $responseModel->getUsers());
$this->users = array_map(fn (User $user): array => self::formatPartialUser($user), $responseModel->getUsers());
}
/** @inheritDoc */
......
......@@ -2,7 +2,6 @@
namespace Source\UseCases\Users\UpdateUser;
use Carbon\Carbon;
use Source\Entities\User;
use Source\Sanitize\CastsTo;
use Source\Entities\Password;
......
......@@ -3,7 +3,6 @@
namespace Tests\Database;
use Carbon\Carbon;
use Source\Entities\Group;
use Tests\DatabaseTestCase;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment