Commit c67adee1 authored by Jacob Priddy's avatar Jacob Priddy 👌

fix code styles

parent 559990b5
......@@ -3,9 +3,7 @@
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Authorizer;
use App\Http\Controllers\Controller;
abstract class ApiController extends Controller
......
......@@ -55,7 +55,11 @@ class DoorController extends ApiController
$presenter = new JsonPresenter();
$this->response->getStatusForDoor(
$this->doorGuard->id(), null, Carbon::now(), Carbon::now()->addMinutes((int)$foresight), $presenter
$this->doorGuard->id(),
null,
Carbon::now(),
Carbon::now()->addMinutes((int)$foresight),
$presenter
);
return $this->respondWithData($presenter->getViewModel());
......
......@@ -4,20 +4,20 @@ namespace App\Http\Controllers\Api;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Source\UseCases\Requests\GetRequests\ApiPresenter as RequestsApiPresenter;
use Source\UseCases\Requests\GetRequests\GetRequestsUseCase;
use Source\UseCases\Requests\ApiPresenter as RequestApiPresenter;
use Source\UseCases\Users\GetUser\GetUserUseCase;
use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Users\UpdateUser\UpdateCurrentUser;
use Source\UseCases\Door\ScheduleEvents\ScheduleEvents;
use Source\UseCases\Users\UpdateUser\UpdateCurrentUser;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Requests\GetRequests\GetRequestsUseCase;
use Source\UseCases\Requests\CreateRequest\CreateRequestUseCase;
use Source\UseCases\GroupUser\GetUserGroups\GetUserGroupsUseCase;
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\Users\UpdateUser\APIPresenter as UpdateUserAPIPresenter;
use Source\UseCases\Requests\GetRequests\ApiPresenter as RequestsApiPresenter;
use Source\UseCases\DoorUser\UserDoorAccess\MePresenter as DoorUserMePresenter;
use Source\UseCases\GroupUser\GetUserGroups\APIPresenter as GetUserGroupsAPIPresenter;
......
......@@ -5,8 +5,8 @@ namespace App\Http\Controllers\Api;
use Carbon\Carbon;
use Illuminate\Http\JsonResponse;
use Source\Authorization\Permissions;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Door\ScheduleEvents\ScheduleEvents;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Schedules\ScheduleGet\ScheduleGetUseCase;
use Source\UseCases\Schedules\SchedulesGet\SchedulesGetUseCase;
use Source\UseCases\Schedules\APIPresenter as ScheduleApiPresenter;
......
......@@ -3,7 +3,6 @@
namespace App\Http\Controllers\Web\Admin;
use Carbon\Carbon;
use Illuminate\View\View;
use App\Http\Controllers\Controller;
......
......@@ -3,12 +3,11 @@
namespace App\Http\Controllers\Web\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Illuminate\Validation\ValidationException;
use Source\Exceptions\AuthenticationException;
use Source\Exceptions\EntityNotFoundException;
use Illuminate\Validation\ValidationException;
use Source\UseCases\Users\Authenticate\WebPresenter;
use Source\UseCases\Users\Authenticate\AuthenticateUseCase;
......
......@@ -2,16 +2,12 @@
namespace App\Http\Controllers\Web;
use Carbon\Carbon;
use Illuminate\View\View;
use Source\Sanitize\CastsTo;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use Source\UseCases\Doors\GetDoors\MePresenter;
use Source\UseCases\Doors\GetDoors\GetDoorsUseCase;
use Source\UseCases\Door\ScheduleEvents\EventsPresenter;
use Source\UseCases\Tokens\GetTokens\GetTokensUseCase;
use Source\UseCases\Door\ScheduleEvents\ScheduleEvents;
use Source\UseCases\Users\UpdateUser\UpdateCurrentUser;
use Source\UseCases\Tokens\GetTokens\WebPresenter as GetTokensWebPresenter;
use Source\UseCases\Users\UpdateUser\WebPresenter as UpdateUserWebPresenter;
......
......@@ -10,7 +10,6 @@ use App\Http\Middleware\AddAjaxHeader;
use App\Http\Middleware\EncryptCookies;
use App\Http\Middleware\VerifyCsrfToken;
use Illuminate\Auth\Middleware\Authorize;
use Illuminate\Auth\Middleware\RequirePassword;
use Illuminate\Http\Middleware\SetCacheHeaders;
use Illuminate\Session\Middleware\StartSession;
use App\Http\Middleware\CheckForMaintenanceMode;
......@@ -18,10 +17,9 @@ use App\Http\Middleware\RedirectIfAuthenticated;
use Illuminate\Routing\Middleware\ThrottleRequests;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\Routing\Middleware\ValidateSignature;
use Illuminate\Auth\Middleware\EnsureEmailIsVerified;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Illuminate\Session\Middleware\AuthenticateSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;
use Illuminate\Auth\Middleware\AuthenticateWithBasicAuth;
use Illuminate\Foundation\Http\Middleware\ValidatePostSize;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateRequestsTable extends Migration
{
......
......@@ -3,14 +3,14 @@
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Api\MeController;
use App\Http\Controllers\Api\AuthController;
use App\Http\Controllers\Api\UsersController;
use App\Http\Controllers\Api\DoorsController;
use App\Http\Controllers\Api\TokensController;
use App\Http\Controllers\Api\UsersController;
use App\Http\Controllers\Api\GroupsController;
use App\Http\Controllers\Api\TokensController;
use App\Http\Controllers\Api\EntriesController;
use App\Http\Controllers\Api\AttemptsController;
use App\Http\Controllers\Api\SchedulesController;
use App\Http\Controllers\Api\OverridesController;
use App\Http\Controllers\Api\SchedulesController;
/*
|--------------------------------------------------------------------------
......
......@@ -46,4 +46,3 @@ Route::name('web.')->middleware(['auth:api'])->group(static function () {
})->name('profile');
});
});
......@@ -3,7 +3,6 @@
namespace Source\Entities;
class DoorFailureRate
{
protected Door $door;
......
......@@ -3,7 +3,6 @@
namespace Source\Entities;
use Carbon\Carbon;
class Request
......@@ -39,8 +38,7 @@ class Request
?string $reply = null,
?Carbon $createdAt = null,
?Carbon $updatedAt = null
)
{
) {
$this->id = $id;
$this->title = $title;
$this->userId = $userId;
......
......@@ -3,9 +3,9 @@
namespace Source\Gateways\Requests;
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
......@@ -24,7 +24,7 @@ class RequestsRepositoryServiceProvider extends ServiceProvider implements Defer
return new LocalRequestsRepository();
}
if(config('app.env') === 'testing') {
if (config('app.env') === 'testing') {
return new InMemoryRequestsRepository();
}
......
......@@ -3,10 +3,10 @@
namespace Source\Gateways\Statistics;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\DatabaseManager;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......@@ -25,7 +25,7 @@ class StatisticsRepositoryServiceProvider extends ServiceProvider implements Def
return new LocalStatisticsRepository();
}
if(config('app.env') === 'testing') {
if (config('app.env') === 'testing') {
return new InMemoryStatisticsRepository();
}
......
......@@ -3,12 +3,12 @@
namespace Source\UseCases\Admin\Statistics;
use Illuminate\Support\ServiceProvider;
use Source\Gateways\Doors\DoorsRepository;
use Source\Gateways\Entries\EntriesRepository;
use Illuminate\Contracts\Foundation\Application;
use Source\Gateways\Requests\RequestsRepository;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
use Source\Gateways\Statistics\StatisticsRepository;
/**
......
......@@ -50,8 +50,8 @@ class WebPresenter extends BasePresenter implements Presenter
}
try {
$this->viewModel['entries']['labels'] = json_encode(array_map(fn(array $entry) => self::formatDateTime($entry[0], self::HUMAN_DAY_FORMAT), $responseModel->getEntryCounts()), JSON_THROW_ON_ERROR);
$this->viewModel['entries']['counts'] = json_encode(array_map(fn(array $entry) => $entry[1], $responseModel->getEntryCounts()), JSON_THROW_ON_ERROR);
$this->viewModel['entries']['labels'] = json_encode(array_map(fn (array $entry) => self::formatDateTime($entry[0], self::HUMAN_DAY_FORMAT), $responseModel->getEntryCounts()), JSON_THROW_ON_ERROR);
$this->viewModel['entries']['counts'] = json_encode(array_map(fn (array $entry) => $entry[1], $responseModel->getEntryCounts()), JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
$this->viewModel['entries'] = [
'labels' => '[]',
......
......@@ -15,7 +15,7 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->attempts = array_map(fn(Attempt $attempt): array => self::formatAttempt($attempt), $responseModel->getAttempts());
$this->attempts = array_map(fn (Attempt $attempt): array => self::formatAttempt($attempt), $responseModel->getAttempts());
}
/** @inheritDoc */
......
......@@ -2,8 +2,8 @@
namespace Source\UseCases\Door\ScheduleEvents;
use Source\UseCases\BasePresenter;
use Source\Entities\ScheduleEvent;
use Source\UseCases\BasePresenter;
class EventsPresenter extends BasePresenter implements Presenter
{
......
......@@ -2,8 +2,8 @@
namespace Source\UseCases\Door\ScheduleEvents;
use Source\UseCases\BasePresenter;
use Source\Entities\ScheduleEvent;
use Source\UseCases\BasePresenter;
class JsonPresenter extends BasePresenter implements Presenter
{
......
......@@ -3,7 +3,6 @@
namespace Source\UseCases\Door\ScheduleEvents;
use Carbon\Carbon;
use Source\Entities\Override;
use Source\Entities\ScheduleEvent;
......
......@@ -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);
}
}
......
......@@ -18,5 +18,4 @@ interface ScheduleEventsUseCase
* @param \Source\UseCases\Door\ScheduleEvents\Presenter $presenter
*/
public function getStatusForDoor(string $doorId, ?string $userId, Carbon $begin, Carbon $end, Presenter $presenter): void;
}
......@@ -15,7 +15,7 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->doors = array_map(fn(Door $door): array => self::formatDoor($door), $responseModel->getDoors());
$this->doors = array_map(fn (Door $door): array => self::formatDoor($door), $responseModel->getDoors());
}
/** @inheritDoc */
......
......@@ -18,12 +18,12 @@ class PrivilegedApiPresenter extends BasePresenter implements Presenter
public function present(ResponseModel $responseModel): void
{
$groups = $responseModel->getGroups();
$this->viewModel['groups'] = array_map(fn(Group $group): array => self::formatGroup($group), $groups);
$this->viewModel['groups'] = array_map(fn (Group $group): array => self::formatGroup($group), $groups);
$this->viewModel['doors'] = [];
$this->viewModel['schedules'] = [];
foreach ($groups as $group) {
$this->viewModel['doors'][$group->getId()] = array_map(fn(Door $door): array => self::formatDoor($door), $responseModel->getDoorsForGroup($group));
$this->viewModel['schedules'][$group->getId()] = array_map(fn(Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedulesForGroup($group));
$this->viewModel['doors'][$group->getId()] = array_map(fn (Door $door): array => self::formatDoor($door), $responseModel->getDoorsForGroup($group));
$this->viewModel['schedules'][$group->getId()] = array_map(fn (Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedulesForGroup($group));
}
}
......
......@@ -15,7 +15,7 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->entries = array_map(fn(Entry $entry): array => self::formatEntry($entry), $responseModel->getEntries());
$this->entries = array_map(fn (Entry $entry): array => self::formatEntry($entry), $responseModel->getEntries());
}
/** @inheritDoc */
......
......@@ -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 */
......
......@@ -15,7 +15,7 @@ class APIPresenter 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,7 +3,6 @@
namespace Source\UseCases;
trait HasErrors
{
/**
......
......@@ -15,7 +15,7 @@ class ApiPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->overrides = array_map(fn(Override $override): array => self::formatOverride($override), $responseModel->getOverrides());
$this->overrides = array_map(fn (Override $override): array => self::formatOverride($override), $responseModel->getOverrides());
}
/** @inheritDoc */
......
......@@ -3,10 +3,10 @@
namespace Source\UseCases\Requests\CreateRequest;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Source\Gateways\Requests\RequestsRepository;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -3,10 +3,10 @@
namespace Source\UseCases\Requests\GetRequest;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Source\Gateways\Requests\RequestsRepository;
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->requests = array_map(static function(Request $request) {
$this->requests = array_map(static function (Request $request) {
return [
'id' => $request->getId(),
'title' => $request->getTitle(),
......
......@@ -3,10 +3,10 @@
namespace Source\UseCases\Requests\GetRequests;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Source\Gateways\Requests\RequestsRepository;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Support\ServiceProvider;
/**
* Service provider must be registered in AppServiceProvider
......
......@@ -3,10 +3,10 @@
namespace Source\UseCases\Requests\InteractWithRequest;
use Illuminate\Support\ServiceProvider;
use Illuminate\Contracts\Foundation\Application;
use Source\Gateways\Requests\RequestsRepository;
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->schedules = array_map(fn(Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
$this->schedules = array_map(fn (Schedule $schedule): array => self::formatSchedule($schedule), $responseModel->getSchedules());
}
/** @inheritDoc */
......
......@@ -15,7 +15,7 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->tokens = array_map(fn(Token $token): array => self::formatToken($token), $responseModel->getTokens());
$this->tokens = array_map(fn (Token $token): array => self::formatToken($token), $responseModel->getTokens());
}
/** @inheritDoc */
......
......@@ -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 */
......
......@@ -56,7 +56,7 @@ class UpdateCurrentUser implements UpdateUserUseCase
if ($doorcode) {
if ($user->getEmplid()) {
$doorcode = $user->getEmplid() . $doorcode;
} else if (strlen($doorcode) < self::MIN_USER_SET_DOORCODE_LEN) {
} elseif (strlen($doorcode) < self::MIN_USER_SET_DOORCODE_LEN) {
$response->setError('Doorcode must be at least ' .
self::MIN_USER_SET_DOORCODE_LEN .
' digits long since you do not have an emplid');
......
......@@ -15,8 +15,8 @@ use Source\Gateways\Doors\DatabaseDoorsRepository;
use Source\Gateways\Users\DatabaseUsersRepository;
use Source\Gateways\Groups\DatabaseGroupsRepository;
use Source\Gateways\DoorGroup\DatabaseDoorGroupRepository;
use Source\Gateways\Schedules\DatabaseSchedulesRepository;
use Source\Gateways\GroupUser\DatabaseGroupUserRepository;
use Source\Gateways\Schedules\DatabaseSchedulesRepository;
use Source\Gateways\DoorSchedule\DatabaseDoorScheduleRepository;
class DoorScheduleDatabaseTest extends 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