@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @param \Flugg\Responder\Http\Responses\ErrorResponseBuilder $errorResponseBuilder |
| 36 | 36 | * @param \Flugg\Responder\Http\Responses\SuccessResponseBuilder $successResponseBuilder |
| 37 | 37 | */ |
| 38 | - public function __construct(ErrorResponseBuilder $errorResponseBuilder, SuccessResponseBuilder $successResponseBuilder) |
|
| 38 | + public function __construct( ErrorResponseBuilder $errorResponseBuilder, SuccessResponseBuilder $successResponseBuilder ) |
|
| 39 | 39 | { |
| 40 | 40 | $this->errorResponseBuilder = $errorResponseBuilder; |
| 41 | 41 | $this->successResponseBuilder = $successResponseBuilder; |
@@ -48,9 +48,9 @@ discard block |
||
| 48 | 48 | * @param string|null $message |
| 49 | 49 | * @return \Flugg\Responder\Http\Responses\ErrorResponseBuilder |
| 50 | 50 | */ |
| 51 | - public function error(string $errorCode = null, string $message = null): ErrorResponseBuilder |
|
| 51 | + public function error( string $errorCode = null, string $message = null ): ErrorResponseBuilder |
|
| 52 | 52 | { |
| 53 | - return $this->errorResponseBuilder->error($errorCode, $message); |
|
| 53 | + return $this->errorResponseBuilder->error( $errorCode, $message ); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | * @param string|null $resourceKey |
| 62 | 62 | * @return \Flugg\Responder\Http\Responses\SuccessResponseBuilder |
| 63 | 63 | */ |
| 64 | - public function success($data = null, $transformer = null, string $resourceKey = null): SuccessResponseBuilder |
|
| 64 | + public function success( $data = null, $transformer = null, string $resourceKey = null ): SuccessResponseBuilder |
|
| 65 | 65 | { |
| 66 | - return $this->successResponseBuilder->transform($data, $transformer, $resourceKey); |
|
| 66 | + return $this->successResponseBuilder->transform( $data, $transformer, $resourceKey ); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | \ No newline at end of file |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - parent::__construct('Given serializer must be an instance of [' . SerializerAbstract::class . '].'); |
|
| 22 | + parent::__construct( 'Given serializer must be an instance of [' . SerializerAbstract::class . '].' ); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -24,14 +24,14 @@ |
||
| 24 | 24 | * @param \Exception $exception |
| 25 | 25 | * @return \Symfony\Component\HttpFoundation\Response |
| 26 | 26 | */ |
| 27 | - public function render($request, Exception $exception) |
|
| 27 | + public function render( $request, Exception $exception ) |
|
| 28 | 28 | { |
| 29 | - $this->transformException($exception); |
|
| 29 | + $this->transformException( $exception ); |
|
| 30 | 30 | |
| 31 | - if ($exception instanceof ApiException) { |
|
| 32 | - return $this->renderApiError($exception); |
|
| 31 | + if ( $exception instanceof ApiException ) { |
|
| 32 | + return $this->renderApiError( $exception ); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - return parent::render($request, $exception); |
|
| 35 | + return parent::render( $request, $exception ); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | * @param \Exception $exception |
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | - protected function transformException(Exception $exception) |
|
| 35 | + protected function transformException( Exception $exception ) |
|
| 36 | 36 | { |
| 37 | - $this->transformAuthException($exception); |
|
| 38 | - $this->transformEloquentException($exception); |
|
| 39 | - $this->transformValidationException($exception); |
|
| 37 | + $this->transformAuthException( $exception ); |
|
| 38 | + $this->transformEloquentException( $exception ); |
|
| 39 | + $this->transformValidationException( $exception ); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | * @throws UnauthenticatedException |
| 48 | 48 | * @throws UnauthorizedException |
| 49 | 49 | */ |
| 50 | - protected function transformAuthException(Exception $exception) |
|
| 50 | + protected function transformAuthException( Exception $exception ) |
|
| 51 | 51 | { |
| 52 | - if ($exception instanceof AuthenticationException) { |
|
| 52 | + if ( $exception instanceof AuthenticationException ) { |
|
| 53 | 53 | throw new UnauthenticatedException; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - if ($exception instanceof AuthorizationException) { |
|
| 56 | + if ( $exception instanceof AuthorizationException ) { |
|
| 57 | 57 | throw new UnauthorizedException; |
| 58 | 58 | } |
| 59 | 59 | } |
@@ -66,13 +66,13 @@ discard block |
||
| 66 | 66 | * @throws ResourceNotFoundException |
| 67 | 67 | * @throws RelationNotFoundException |
| 68 | 68 | */ |
| 69 | - protected function transformEloquentException(Exception $exception) |
|
| 69 | + protected function transformEloquentException( Exception $exception ) |
|
| 70 | 70 | { |
| 71 | - if ($exception instanceof ModelNotFoundException) { |
|
| 71 | + if ( $exception instanceof ModelNotFoundException ) { |
|
| 72 | 72 | throw new ResourceNotFoundException; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ($exception instanceof BaseRelationNotFoundException) { |
|
| 75 | + if ( $exception instanceof BaseRelationNotFoundException ) { |
|
| 76 | 76 | throw new RelationNotFoundException; |
| 77 | 77 | } |
| 78 | 78 | } |
@@ -84,10 +84,10 @@ discard block |
||
| 84 | 84 | * @return void |
| 85 | 85 | * @throws ValidationFailedException |
| 86 | 86 | */ |
| 87 | - protected function transformValidationException(Exception $exception) |
|
| 87 | + protected function transformValidationException( Exception $exception ) |
|
| 88 | 88 | { |
| 89 | - if ($exception instanceof ValidationException) { |
|
| 90 | - throw new ValidationFailedException($exception->validator); |
|
| 89 | + if ( $exception instanceof ValidationException ) { |
|
| 90 | + throw new ValidationFailedException( $exception->validator ); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | * @param \Flugg\Responder\Exceptions\Http\ApiException $exception |
| 98 | 98 | * @return \Illuminate\Http\JsonResponse |
| 99 | 99 | */ |
| 100 | - protected function renderApiError(ApiException $exception): JsonResponse |
|
| 100 | + protected function renderApiError( ApiException $exception ): JsonResponse |
|
| 101 | 101 | { |
| 102 | - return $this->container->make(ErrorResponseBuilder::class) |
|
| 103 | - ->error($exception->errorCode(), $exception->message()) |
|
| 104 | - ->data($exception->data()) |
|
| 105 | - ->respond($exception->statusCode()); |
|
| 102 | + return $this->container->make( ErrorResponseBuilder::class ) |
|
| 103 | + ->error( $exception->errorCode(), $exception->message() ) |
|
| 104 | + ->data( $exception->data() ) |
|
| 105 | + ->respond( $exception->statusCode() ); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | \ No newline at end of file |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param \Illuminate\Contracts\Validation\Validator $validator |
| 42 | 42 | */ |
| 43 | - public function __construct(Validator $validator) |
|
| 43 | + public function __construct( Validator $validator ) |
|
| 44 | 44 | { |
| 45 | 45 | $this->validator = $validator; |
| 46 | 46 | |
@@ -54,6 +54,6 @@ discard block |
||
| 54 | 54 | */ |
| 55 | 55 | public function data() |
| 56 | 56 | { |
| 57 | - return [$this->validator->getMessageBag()->toArray()]; |
|
| 57 | + return [ $this->validator->getMessageBag()->toArray() ]; |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | \ No newline at end of file |
@@ -19,6 +19,6 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | public function __construct() |
| 21 | 21 | { |
| 22 | - parent::__construct('Given transformer must be a callable or an instance of [' . Transformer::class . '].'); |
|
| 22 | + parent::__construct( 'Given transformer must be a callable or an instance of [' . Transformer::class . '].' ); |
|
| 23 | 23 | } |
| 24 | 24 | } |
| 25 | 25 | \ No newline at end of file |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * |
| 30 | 30 | * @param array $parameters |
| 31 | 31 | */ |
| 32 | - public function __construct(array $parameters) |
|
| 32 | + public function __construct( array $parameters ) |
|
| 33 | 33 | { |
| 34 | 34 | $this->parameters = $parameters; |
| 35 | 35 | } |
@@ -40,11 +40,11 @@ discard block |
||
| 40 | 40 | * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator |
| 41 | 41 | * @return \League\Fractal\Pagination\PaginatorInterface |
| 42 | 42 | */ |
| 43 | - public function make(LengthAwarePaginator $paginator): PaginatorInterface |
|
| 43 | + public function make( LengthAwarePaginator $paginator ): PaginatorInterface |
|
| 44 | 44 | { |
| 45 | - $paginator->appends($this->parameters); |
|
| 45 | + $paginator->appends( $this->parameters ); |
|
| 46 | 46 | |
| 47 | - return new IlluminatePaginatorAdapter($paginator); |
|
| 47 | + return new IlluminatePaginatorAdapter( $paginator ); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | * @param \Flugg\Responder\Pagination\CursorPaginator $paginator |
| 54 | 54 | * @return \League\Fractal\Pagination\Cursor |
| 55 | 55 | */ |
| 56 | - public function makeCursor(CursorPaginator $paginator): Cursor |
|
| 56 | + public function makeCursor( CursorPaginator $paginator ): Cursor |
|
| 57 | 57 | { |
| 58 | - $paginator->appends($this->parameters); |
|
| 58 | + $paginator->appends( $this->parameters ); |
|
| 59 | 59 | |
| 60 | - return new Cursor($paginator->cursor(), $paginator->previous(), $paginator->next(), $paginator->get()->count()); |
|
| 60 | + return new Cursor( $paginator->cursor(), $paginator->previous(), $paginator->next(), $paginator->get()->count() ); |
|
| 61 | 61 | } |
| 62 | 62 | } |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * @param int|string|null $previousCursor |
| 59 | 59 | * @param int|string|null $nextCursor |
| 60 | 60 | */ |
| 61 | - public function __construct($data, $cursor, $previousCursor, $nextCursor) |
|
| 61 | + public function __construct( $data, $cursor, $previousCursor, $nextCursor ) |
|
| 62 | 62 | { |
| 63 | 63 | $this->cursor = $cursor; |
| 64 | 64 | $this->previousCursor = $previousCursor; |
| 65 | 65 | $this->nextCursor = $nextCursor; |
| 66 | 66 | |
| 67 | - $this->set($data); |
|
| 67 | + $this->set( $data ); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | * @param \Illuminate\Support\Collection|array|null $data |
| 124 | 124 | * @return self |
| 125 | 125 | */ |
| 126 | - public function set($data): CursorPaginator |
|
| 126 | + public function set( $data ): CursorPaginator |
|
| 127 | 127 | { |
| 128 | - $this->items = $data instanceof Collection ? $data : Collection::make($data);; |
|
| 128 | + $this->items = $data instanceof Collection ? $data : Collection::make( $data ); ; |
|
| 129 | 129 | |
| 130 | 130 | return $this; |
| 131 | 131 | } |
@@ -137,13 +137,13 @@ discard block |
||
| 137 | 137 | * @return mixed |
| 138 | 138 | * @throws \LogicException |
| 139 | 139 | */ |
| 140 | - public static function resolveCursor(string $name = 'cursor') |
|
| 140 | + public static function resolveCursor( string $name = 'cursor' ) |
|
| 141 | 141 | { |
| 142 | - if (isset(static::$currentCursorResolver)) { |
|
| 143 | - return call_user_func(static::$currentCursorResolver, $name); |
|
| 142 | + if ( isset(static::$currentCursorResolver) ) { |
|
| 143 | + return call_user_func( static::$currentCursorResolver, $name ); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - throw new LogicException("Could not resolve cursor with the name [{$name}]."); |
|
| 146 | + throw new LogicException( "Could not resolve cursor with the name [{$name}]." ); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | /** |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param \Closure $resolver |
| 153 | 153 | * @return void |
| 154 | 154 | */ |
| 155 | - public static function cursorResolver(Closure $resolver) |
|
| 155 | + public static function cursorResolver( Closure $resolver ) |
|
| 156 | 156 | { |
| 157 | 157 | static::$currentCursorResolver = $resolver; |
| 158 | 158 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * @param array $data |
| 22 | 22 | * @return array |
| 23 | 23 | */ |
| 24 | - public function collection($resourceKey, array $data) |
|
| 24 | + public function collection( $resourceKey, array $data ) |
|
| 25 | 25 | { |
| 26 | 26 | return $data; |
| 27 | 27 | } |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param array $data |
| 34 | 34 | * @return array |
| 35 | 35 | */ |
| 36 | - public function item($resourceKey, array $data) |
|
| 36 | + public function item( $resourceKey, array $data ) |
|
| 37 | 37 | { |
| 38 | 38 | return $data; |
| 39 | 39 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | */ |
| 46 | 46 | public function null() |
| 47 | 47 | { |
| 48 | - return []; |
|
| 48 | + return [ ]; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -54,9 +54,9 @@ discard block |
||
| 54 | 54 | * @param array $meta |
| 55 | 55 | * @return array |
| 56 | 56 | */ |
| 57 | - public function meta(array $meta) |
|
| 57 | + public function meta( array $meta ) |
|
| 58 | 58 | { |
| 59 | - return []; |
|
| 59 | + return [ ]; |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | * @param \League\Fractal\Pagination\PaginatorInterface $paginator |
| 66 | 66 | * @return array |
| 67 | 67 | */ |
| 68 | - public function paginator(PaginatorInterface $paginator) |
|
| 68 | + public function paginator( PaginatorInterface $paginator ) |
|
| 69 | 69 | { |
| 70 | - return []; |
|
| 70 | + return [ ]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -76,9 +76,9 @@ discard block |
||
| 76 | 76 | * @param \League\Fractal\Pagination\CursorInterface $cursor |
| 77 | 77 | * @return array |
| 78 | 78 | */ |
| 79 | - public function cursor(CursorInterface $cursor) |
|
| 79 | + public function cursor( CursorInterface $cursor ) |
|
| 80 | 80 | { |
| 81 | - return []; |
|
| 81 | + return [ ]; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -88,8 +88,8 @@ discard block |
||
| 88 | 88 | * @param array $includedData |
| 89 | 89 | * @return array |
| 90 | 90 | */ |
| 91 | - public function mergeIncludes($transformedData, $includedData) |
|
| 91 | + public function mergeIncludes( $transformedData, $includedData ) |
|
| 92 | 92 | { |
| 93 | - return array_merge($transformedData, $includedData); |
|
| 93 | + return array_merge( $transformedData, $includedData ); |
|
| 94 | 94 | } |
| 95 | 95 | } |