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

fix code styles

parent 747f3465
......@@ -10,3 +10,4 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
.php_cs.cache
......@@ -3,17 +3,18 @@
namespace App\Console\Commands\GatewayCommands;
use Illuminate\Console\GeneratorCommand;
abstract class BaseGatewayFileGenerator extends GeneratorCommand {
abstract class BaseGatewayFileGenerator extends GeneratorCommand
{
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace) {
protected function getDefaultNamespace($rootNamespace)
{
$namespace = $rootNamespace . '\\Gateways';
foreach (explode('/', $this->getNameInput()) as $folder) {
$namespace .= '\\' . $folder;
......@@ -27,7 +28,8 @@ abstract class BaseGatewayFileGenerator extends GeneratorCommand {
* @param string $name
* @return string
*/
protected function getNamespace($name) {
protected function getNamespace($name)
{
return $this->getDefaultNamespace($this->rootNamespace());
}
......@@ -38,7 +40,8 @@ abstract class BaseGatewayFileGenerator extends GeneratorCommand {
* @param string $name
* @return string
*/
protected function replaceClass($stub, $name) {
protected function replaceClass($stub, $name)
{
$name = last(explode('\\', $name));
return parent::replaceClass($stub, $name);
}
......@@ -48,7 +51,8 @@ abstract class BaseGatewayFileGenerator extends GeneratorCommand {
*
* @return string
*/
public function rootNamespace() {
public function rootNamespace()
{
return 'Source';
}
}
......@@ -3,10 +3,10 @@
namespace App\Console\Commands\GatewayCommands;
use Illuminate\Console\Command;
class CreateGateway extends Command {
class CreateGateway extends Command
{
/**
* The name and signature of the console command.
*
......@@ -24,7 +24,8 @@ class CreateGateway extends Command {
/**
* Execute the console command.
*/
public function handle(): void {
public function handle(): void
{
$name = $this->argument('name');
$this->call(
'gateway:create-interface',
......
......@@ -3,8 +3,8 @@
namespace App\Console\Commands\GatewayCommands;
class GenerateBaseGateway extends BaseGatewayFileGenerator {
class GenerateBaseGateway extends BaseGatewayFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -31,7 +31,8 @@ class GenerateBaseGateway extends BaseGatewayFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/Repository.stub';
}
......@@ -41,7 +42,8 @@ class GenerateBaseGateway extends BaseGatewayFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$baseName = $this->getNameInput();
$className = last(explode('/', $baseName));
......
......@@ -3,8 +3,8 @@
namespace App\Console\Commands\GatewayCommands;
class GenerateGatewayRepositoryType extends BaseGatewayFileGenerator {
class GenerateGatewayRepositoryType extends BaseGatewayFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -31,7 +31,8 @@ class GenerateGatewayRepositoryType extends BaseGatewayFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
$type = $this->argument('type');
return __DIR__ . '/stubs/' . ucfirst($type) . '.stub';
}
......@@ -42,7 +43,8 @@ class GenerateGatewayRepositoryType extends BaseGatewayFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$name = $this->getNameInput();
$type = $this->argument('type');
return $this->laravel->basePath() . '/src/Gateways/' . $name . '/' . $type . $name . 'Repository.php';
......
......@@ -3,8 +3,8 @@
namespace App\Console\Commands\GatewayCommands;
class GenerateGatewayServiceProvider extends BaseGatewayFileGenerator {
class GenerateGatewayServiceProvider extends BaseGatewayFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -31,7 +31,8 @@ class GenerateGatewayServiceProvider extends BaseGatewayFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/Provider.stub';
}
......@@ -41,7 +42,8 @@ class GenerateGatewayServiceProvider extends BaseGatewayFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$fullName = $this->getNameInput();
$className = last(explode('/', $fullName));
......
......@@ -4,14 +4,16 @@ namespace App\Console\Commands\UseCaseCommands;
use Illuminate\Console\GeneratorCommand;
abstract class BaseUseCaseFileGenerator extends GeneratorCommand {
abstract class BaseUseCaseFileGenerator extends GeneratorCommand
{
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
*/
protected function getDefaultNamespace($rootNamespace) {
protected function getDefaultNamespace($rootNamespace)
{
$namespace = $rootNamespace . '\\UseCases';
foreach (explode('/', $this->getNameInput()) as $folder) {
$namespace .= '\\' . $folder;
......@@ -25,7 +27,8 @@ abstract class BaseUseCaseFileGenerator extends GeneratorCommand {
* @param string $name
* @return string
*/
protected function getNamespace($name) {
protected function getNamespace($name)
{
return $this->getDefaultNamespace($this->rootNamespace());
}
......@@ -36,7 +39,8 @@ abstract class BaseUseCaseFileGenerator extends GeneratorCommand {
* @param string $name
* @return string
*/
protected function replaceClass($stub, $name) {
protected function replaceClass($stub, $name)
{
$name = last(explode('\\', $name));
return parent::replaceClass($stub, $name);
}
......@@ -46,7 +50,8 @@ abstract class BaseUseCaseFileGenerator extends GeneratorCommand {
*
* @return string
*/
public function rootNamespace() {
public function rootNamespace()
{
return 'Source';
}
}
......@@ -4,7 +4,8 @@ namespace App\Console\Commands\UseCaseCommands;
use Illuminate\Console\Command;
class CreateUseCase extends Command {
class CreateUseCase extends Command
{
/**
* The name and signature of the console command.
*
......@@ -22,7 +23,8 @@ class CreateUseCase extends Command {
/**
* Execute the console command.
*/
public function handle(): void {
public function handle(): void
{
$name = $this->argument('name');
$this->call(
'use-case:create-use-case',
......
......@@ -2,7 +2,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateBaseUseCase extends BaseUseCaseFileGenerator {
class GenerateBaseUseCase extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -29,7 +30,8 @@ class GenerateBaseUseCase extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/BaseUseCase.stub';
}
......@@ -39,7 +41,8 @@ class GenerateBaseUseCase extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$baseName = $this->getNameInput();
$className = last(explode('/', $baseName));
......
......@@ -2,7 +2,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateUseCase extends BaseUseCaseFileGenerator {
class GenerateUseCase extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -29,7 +30,8 @@ class GenerateUseCase extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/UseCase.stub';
}
......@@ -39,7 +41,8 @@ class GenerateUseCase extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$name = $this->getNameInput();
$className = last(explode('/', $name));
......
......@@ -2,7 +2,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateUseCasePresenter extends BaseUseCaseFileGenerator {
class GenerateUseCasePresenter extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -29,7 +30,8 @@ class GenerateUseCasePresenter extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/presenter.stub';
}
......@@ -39,7 +41,8 @@ class GenerateUseCasePresenter extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$name = $this->getNameInput();
return $this->laravel->basePath() . '/src/UseCases/' . $name . '/Presenter.php';
}
......
......@@ -2,7 +2,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateUseCasePresenterType extends BaseUseCaseFileGenerator {
class GenerateUseCasePresenterType extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -29,7 +30,8 @@ class GenerateUseCasePresenterType extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/PresenterType.stub';
}
......@@ -39,7 +41,8 @@ class GenerateUseCasePresenterType extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$name = $this->getNameInput();
$type = $this->argument('type');
return $this->laravel->basePath() . '/src/UseCases/' . $name . '/' . $type . 'Presenter.php';
......@@ -52,7 +55,8 @@ class GenerateUseCasePresenterType extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function replaceClass($stub, $name) {
protected function replaceClass($stub, $name)
{
$type = $this->argument('type');
$name = $type . 'Presenter';
return parent::replaceClass($stub, $name);
......
......@@ -2,7 +2,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateUseCaseResponseModel extends BaseUseCaseFileGenerator {
class GenerateUseCaseResponseModel extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -29,7 +30,8 @@ class GenerateUseCaseResponseModel extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/ResponseModel.stub';
}
......@@ -39,7 +41,8 @@ class GenerateUseCaseResponseModel extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$name = $this->getNameInput();
return $this->laravel->basePath() . '/src/UseCases/' . $name . '/ResponseModel.php';
}
......
......@@ -3,8 +3,8 @@
namespace App\Console\Commands\UseCaseCommands;
class GenerateUseCaseServiceProvider extends BaseUseCaseFileGenerator {
class GenerateUseCaseServiceProvider extends BaseUseCaseFileGenerator
{
/**
* The name and signature of the console command.
*
......@@ -31,7 +31,8 @@ class GenerateUseCaseServiceProvider extends BaseUseCaseFileGenerator {
*
* @return string
*/
protected function getStub() {
protected function getStub()
{
return __DIR__ . '/stubs/Provider.stub';
}
......@@ -41,7 +42,8 @@ class GenerateUseCaseServiceProvider extends BaseUseCaseFileGenerator {
* @param string $name
* @return string
*/
protected function getPath($name) {
protected function getPath($name)
{
$fullName = $this->getNameInput();
$className = last(explode('/', $fullName));
......
......@@ -4,7 +4,8 @@ namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class Door extends Authenticatable {
class Door extends Authenticatable
{
protected $fillable = [
'*'
];
......
......@@ -5,16 +5,17 @@ namespace App\Exceptions;
use Exception;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Source\Exceptions\EntityExistsException;
use Illuminate\Auth\AuthenticationException;
use Source\Exceptions\EntityExistsException;
use Source\Exceptions\AuthorizationException;
use Source\Exceptions\EntityNotFoundException;
use Illuminate\Validation\ValidationException;
use Source\Exceptions\EntityNotFoundException;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Source\Exceptions\AuthenticationException as SourceAuthenticationException;
class Handler extends ExceptionHandler {
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
......@@ -32,7 +33,8 @@ class Handler extends ExceptionHandler {
* @param int $code
* @return JsonResponse
*/
public function respondWithError(string $message, int $code): JsonResponse {
public function respondWithError(string $message, int $code): JsonResponse
{
return new JsonResponse(
[
'status' => 'error',
......@@ -51,7 +53,8 @@ class Handler extends ExceptionHandler {
* @return Response
* @throws Exception
*/
public function render($request, Exception $exception) {
public function render($request, Exception $exception)
{
if (
$exception instanceof EntityNotFoundException ||
$exception instanceof EntityExistsException
......@@ -77,7 +80,8 @@ class Handler extends ExceptionHandler {
* @param AuthenticationException $exception
* @return Response
*/
protected function unauthenticated($request, AuthenticationException $exception) {
protected function unauthenticated($request, AuthenticationException $exception)
{
return response()->json(['message' => $exception->getMessage()], 401);
}
......@@ -88,7 +92,8 @@ class Handler extends ExceptionHandler {
* @param Request $request
* @return Response
*/
protected function convertValidationExceptionToResponse(ValidationException $e, $request) {
protected function convertValidationExceptionToResponse(ValidationException $e, $request)
{
if ($e->response) {
return $e->response;
}
......
......@@ -3,7 +3,6 @@
namespace App;
class Group {
class Group
{
}
......@@ -3,7 +3,6 @@
namespace App\Guards;
use Illuminate\Http\Request;
use Illuminate\Auth\GuardHelpers;
use Illuminate\Contracts\Auth\Guard;
......@@ -11,7 +10,8 @@ use Illuminate\Contracts\Auth\Authenticatable;
use Source\UseCases\Token\Authenticate\AuthenticateUseCase;
use Source\UseCases\Token\Authenticate\TranslationPresenter;
class ApiGuard implements Guard {
class ApiGuard implements Guard
{
use GuardHelpers;
/**
......@@ -43,7 +43,8 @@ class ApiGuard implements Guard {
public function __construct(
AuthenticateUseCase $authenticator,
Request $request,
$inputKey = 'api_token'){
$inputKey = 'api_token'
) {
$this->request = $request;
$this->inputKey = $inputKey;
$this->authenticator = $authenticator;
......@@ -54,7 +55,8 @@ class ApiGuard implements Guard {
*
* @return Authenticatable|null
*/
public function user() {