@@ -22,9 +22,9 @@ discard block |
||
| 22 | 22 | * @param array $data |
| 23 | 23 | * @return array |
| 24 | 24 | */ |
| 25 | - public function collection($resourceKey, array $data) |
|
| 25 | + public function collection( $resourceKey, array $data ) |
|
| 26 | 26 | { |
| 27 | - return $this->item($resourceKey, $data); |
|
| 27 | + return $this->item( $resourceKey, $data ); |
|
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | /** |
@@ -34,11 +34,11 @@ discard block |
||
| 34 | 34 | * @param array $data |
| 35 | 35 | * @return array |
| 36 | 36 | */ |
| 37 | - public function item($resourceKey, array $data) |
|
| 37 | + public function item( $resourceKey, array $data ) |
|
| 38 | 38 | { |
| 39 | - return array_merge($this->null(), [ |
|
| 39 | + return array_merge( $this->null(), [ |
|
| 40 | 40 | 'data' => $data |
| 41 | - ]); |
|
| 41 | + ] ); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param array $meta |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function meta(array $meta) |
|
| 63 | + public function meta( array $meta ) |
|
| 64 | 64 | { |
| 65 | 65 | return $meta; |
| 66 | 66 | } |
@@ -72,19 +72,19 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return array |
| 74 | 74 | */ |
| 75 | - public function paginator(PaginatorInterface $paginator) |
|
| 75 | + public function paginator( PaginatorInterface $paginator ) |
|
| 76 | 76 | { |
| 77 | - $pagination = parent::paginator($paginator)['pagination']; |
|
| 77 | + $pagination = parent::paginator( $paginator )[ 'pagination' ]; |
|
| 78 | 78 | |
| 79 | 79 | $data = [ |
| 80 | - 'total' => $pagination['total'], |
|
| 81 | - 'count' => $pagination['count'], |
|
| 82 | - 'perPage' => $pagination['per_page'], |
|
| 83 | - 'currentPage' => $pagination['current_page'], |
|
| 84 | - 'totalPages' => $pagination['total_pages'], |
|
| 80 | + 'total' => $pagination[ 'total' ], |
|
| 81 | + 'count' => $pagination[ 'count' ], |
|
| 82 | + 'perPage' => $pagination[ 'per_page' ], |
|
| 83 | + 'currentPage' => $pagination[ 'current_page' ], |
|
| 84 | + 'totalPages' => $pagination[ 'total_pages' ], |
|
| 85 | 85 | ]; |
| 86 | 86 | |
| 87 | - return ['pagination' => $data]; |
|
| 87 | + return [ 'pagination' => $data ]; |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | /** |
@@ -104,15 +104,15 @@ discard block |
||
| 104 | 104 | * @param array $includedData |
| 105 | 105 | * @return array |
| 106 | 106 | */ |
| 107 | - public function mergeIncludes($transformedData, $includedData) |
|
| 107 | + public function mergeIncludes( $transformedData, $includedData ) |
|
| 108 | 108 | { |
| 109 | - $keys = array_keys($includedData); |
|
| 109 | + $keys = array_keys( $includedData ); |
|
| 110 | 110 | |
| 111 | - foreach ($keys as $key) { |
|
| 112 | - $includedData[$key] = $includedData[$key]['data']; |
|
| 111 | + foreach ( $keys as $key ) { |
|
| 112 | + $includedData[ $key ] = $includedData[ $key ][ 'data' ]; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - return array_merge($transformedData, $includedData); |
|
| 115 | + return array_merge( $transformedData, $includedData ); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -123,8 +123,8 @@ discard block |
||
| 123 | 123 | * |
| 124 | 124 | * @return array |
| 125 | 125 | */ |
| 126 | - public function includedData(ResourceInterface $resource, array $data) |
|
| 126 | + public function includedData( ResourceInterface $resource, array $data ) |
|
| 127 | 127 | { |
| 128 | - return []; |
|
| 128 | + return [ ]; |
|
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | \ No newline at end of file |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @var array |
| 23 | 23 | */ |
| 24 | - protected $data = []; |
|
| 24 | + protected $data = [ ]; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * The error code used to identify the error. |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @var array |
| 44 | 44 | */ |
| 45 | - protected $parameters = []; |
|
| 45 | + protected $parameters = [ ]; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * The HTTP status code for the response. |
@@ -64,11 +64,11 @@ discard block |
||
| 64 | 64 | * @param \Illuminate\Contracts\Routing\ResponseFactory $responseFactory |
| 65 | 65 | * @param \Symfony\Component\Translation\TranslatorInterface $translator |
| 66 | 66 | */ |
| 67 | - public function __construct(ResponseFactory $responseFactory, TranslatorInterface $translator) |
|
| 67 | + public function __construct( ResponseFactory $responseFactory, TranslatorInterface $translator ) |
|
| 68 | 68 | { |
| 69 | 69 | $this->translator = $translator; |
| 70 | 70 | |
| 71 | - parent::__construct($responseFactory); |
|
| 71 | + parent::__construct( $responseFactory ); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | * @param array $data |
| 78 | 78 | * @return self |
| 79 | 79 | */ |
| 80 | - public function addData(array $data):ErrorResponseBuilder |
|
| 80 | + public function addData( array $data ):ErrorResponseBuilder |
|
| 81 | 81 | { |
| 82 | - $this->data = array_merge($this->data, $data); |
|
| 82 | + $this->data = array_merge( $this->data, $data ); |
|
| 83 | 83 | |
| 84 | 84 | return $this; |
| 85 | 85 | } |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | * @param string|array|null $message |
| 92 | 92 | * @return self |
| 93 | 93 | */ |
| 94 | - public function setError(string $errorCode = null, $message = null):ErrorResponseBuilder |
|
| 94 | + public function setError( string $errorCode = null, $message = null ):ErrorResponseBuilder |
|
| 95 | 95 | { |
| 96 | 96 | $this->errorCode = $errorCode; |
| 97 | 97 | |
| 98 | - if (is_array($message)) { |
|
| 98 | + if ( is_array( $message ) ) { |
|
| 99 | 99 | $this->parameters = $message; |
| 100 | 100 | } else { |
| 101 | 101 | $this->message = $message; |
@@ -111,13 +111,13 @@ discard block |
||
| 111 | 111 | * @return self |
| 112 | 112 | * @throws \InvalidArgumentException |
| 113 | 113 | */ |
| 114 | - public function setStatus(int $statusCode):ResponseBuilder |
|
| 114 | + public function setStatus( int $statusCode ):ResponseBuilder |
|
| 115 | 115 | { |
| 116 | - if ($statusCode < 400 || $statusCode >= 600) { |
|
| 117 | - throw new InvalidArgumentException("{$statusCode} is not a valid error HTTP status code."); |
|
| 116 | + if ( $statusCode < 400 || $statusCode >= 600 ) { |
|
| 117 | + throw new InvalidArgumentException( "{$statusCode} is not a valid error HTTP status code." ); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | - return parent::setStatus($statusCode); |
|
| 120 | + return parent::setStatus( $statusCode ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | */ |
| 141 | 141 | protected function buildErrorData() |
| 142 | 142 | { |
| 143 | - if (is_null($this->errorCode)) { |
|
| 143 | + if ( is_null( $this->errorCode ) ) { |
|
| 144 | 144 | return null; |
| 145 | 145 | } |
| 146 | 146 | |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | 'message' => $this->message ?: $this->resolveMessage() |
| 150 | 150 | ]; |
| 151 | 151 | |
| 152 | - return array_merge($data, $this->data); |
|
| 152 | + return array_merge( $data, $this->data ); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -159,10 +159,10 @@ discard block |
||
| 159 | 159 | */ |
| 160 | 160 | protected function resolveMessage() |
| 161 | 161 | { |
| 162 | - if (! $this->translator->has($code = "errors.$this->errorCode")) { |
|
| 162 | + if ( ! $this->translator->has( $code = "errors.$this->errorCode" ) ) { |
|
| 163 | 163 | return null; |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | - return $this->translator->trans($code, $this->parameters); |
|
| 166 | + return $this->translator->trans( $code, $this->parameters ); |
|
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | \ No newline at end of file |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | use Flugg\Responder\Responder; |
| 4 | 4 | |
| 5 | -if (! function_exists('responder')) { |
|
| 5 | +if ( ! function_exists( 'responder' ) ) { |
|
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | 8 | * A helper method to quickly resolve the responder out of the service container. |
@@ -11,6 +11,6 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | function responder() |
| 13 | 13 | { |
| 14 | - return app(Responder::class); |
|
| 14 | + return app( Responder::class ); |
|
| 15 | 15 | } |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -46,17 +46,17 @@ discard block |
||
| 46 | 46 | * @param mixed|null $data |
| 47 | 47 | * @return \League\Fractal\Resource\ResourceInterface |
| 48 | 48 | */ |
| 49 | - public function make($data = null) |
|
| 49 | + public function make( $data = null ) |
|
| 50 | 50 | { |
| 51 | - if (is_null($data)) { |
|
| 51 | + if ( is_null( $data ) ) { |
|
| 52 | 52 | return new NullResource(); |
| 53 | - } elseif (is_array($data)) { |
|
| 54 | - return static::makeFromArray($data); |
|
| 53 | + } elseif ( is_array( $data ) ) { |
|
| 54 | + return static::makeFromArray( $data ); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $method = static::getMakeMethod($data); |
|
| 57 | + $method = static::getMakeMethod( $data ); |
|
| 58 | 58 | |
| 59 | - return static::$method($data); |
|
| 59 | + return static::$method( $data ); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | /** |
@@ -66,15 +66,15 @@ discard block |
||
| 66 | 66 | * @return string |
| 67 | 67 | * @throws \InvalidArgumentException |
| 68 | 68 | */ |
| 69 | - protected function getMakeMethod($data):string |
|
| 69 | + protected function getMakeMethod( $data ):string |
|
| 70 | 70 | { |
| 71 | - foreach (static::MAKE_METHODS as $class => $method) { |
|
| 72 | - if ($data instanceof $class) { |
|
| 71 | + foreach ( static::MAKE_METHODS as $class => $method ) { |
|
| 72 | + if ( $data instanceof $class ) { |
|
| 73 | 73 | return $method; |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - throw new InvalidArgumentException('Given data cannot be transformed.'); |
|
| 77 | + throw new InvalidArgumentException( 'Given data cannot be transformed.' ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | * @param \Illuminate\Database\Eloquent\Model $model |
| 84 | 84 | * @return \League\Fractal\Resource\ResourceInterface |
| 85 | 85 | */ |
| 86 | - protected function makeFromModel(Model $model):ResourceInterface |
|
| 86 | + protected function makeFromModel( Model $model ):ResourceInterface |
|
| 87 | 87 | { |
| 88 | - return new ItemResource($model); |
|
| 88 | + return new ItemResource( $model ); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -94,9 +94,9 @@ discard block |
||
| 94 | 94 | * @param array $array |
| 95 | 95 | * @return \League\Fractal\Resource\ResourceInterface |
| 96 | 96 | */ |
| 97 | - protected function makeFromArray(array $array):ResourceInterface |
|
| 97 | + protected function makeFromArray( array $array ):ResourceInterface |
|
| 98 | 98 | { |
| 99 | - return empty($array) ? new NullResource() : new CollectionResource($array); |
|
| 99 | + return empty($array) ? new NullResource() : new CollectionResource( $array ); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | /** |
@@ -105,9 +105,9 @@ discard block |
||
| 105 | 105 | * @param \Illuminate\Support\Collection $collection |
| 106 | 106 | * @return \League\Fractal\Resource\ResourceInterface |
| 107 | 107 | */ |
| 108 | - protected function makeFromCollection(Collection $collection):ResourceInterface |
|
| 108 | + protected function makeFromCollection( Collection $collection ):ResourceInterface |
|
| 109 | 109 | { |
| 110 | - return static::makeFromArray($collection->all()); |
|
| 110 | + return static::makeFromArray( $collection->all() ); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | 113 | /** |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | * @param \Illuminate\Database\Eloquent\Builder $query |
| 117 | 117 | * @return \League\Fractal\Resource\ResourceInterface |
| 118 | 118 | */ |
| 119 | - protected function makeFromBuilder(Builder $query):ResourceInterface |
|
| 119 | + protected function makeFromBuilder( Builder $query ):ResourceInterface |
|
| 120 | 120 | { |
| 121 | - return static::makeFromCollection($query->get()); |
|
| 121 | + return static::makeFromCollection( $query->get() ); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
@@ -127,12 +127,12 @@ discard block |
||
| 127 | 127 | * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator |
| 128 | 128 | * @return \League\Fractal\Resource\ResourceInterface |
| 129 | 129 | */ |
| 130 | - protected function makeFromPaginator(Paginator $paginator):ResourceInterface |
|
| 130 | + protected function makeFromPaginator( Paginator $paginator ):ResourceInterface |
|
| 131 | 131 | { |
| 132 | - $resource = static::makeFromCollection($paginator->getCollection()); |
|
| 132 | + $resource = static::makeFromCollection( $paginator->getCollection() ); |
|
| 133 | 133 | |
| 134 | - if ($resource instanceof CollectionResource) { |
|
| 135 | - $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); |
|
| 134 | + if ( $resource instanceof CollectionResource ) { |
|
| 135 | + $resource->setPaginator( new IlluminatePaginatorAdapter( $paginator ) ); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | return $resource; |
@@ -144,9 +144,9 @@ discard block |
||
| 144 | 144 | * @param \Illuminate\Database\Eloquent\Relations\Pivot $pivot |
| 145 | 145 | * @return \League\Fractal\Resource\ResourceInterface |
| 146 | 146 | */ |
| 147 | - protected function makeFromPivot(Pivot $pivot):ResourceInterface |
|
| 147 | + protected function makeFromPivot( Pivot $pivot ):ResourceInterface |
|
| 148 | 148 | { |
| 149 | - return static::makeFromModel($pivot); |
|
| 149 | + return static::makeFromModel( $pivot ); |
|
| 150 | 150 | } |
| 151 | 151 | |
| 152 | 152 | /** |
@@ -155,8 +155,8 @@ discard block |
||
| 155 | 155 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
| 156 | 156 | * @return \League\Fractal\Resource\ResourceInterface |
| 157 | 157 | */ |
| 158 | - protected function makeFromRelation(Relation $relation):ResourceInterface |
|
| 158 | + protected function makeFromRelation( Relation $relation ):ResourceInterface |
|
| 159 | 159 | { |
| 160 | - return static::makeFromCollection($relation->get()); |
|
| 160 | + return static::makeFromCollection( $relation->get() ); |
|
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | \ No newline at end of file |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | * |
| 40 | 40 | * @param Validator $validator |
| 41 | 41 | */ |
| 42 | - public function __construct(Validator $validator) |
|
| 42 | + public function __construct( Validator $validator ) |
|
| 43 | 43 | { |
| 44 | 44 | $this->validator = $validator; |
| 45 | 45 | |
@@ -53,6 +53,6 @@ discard block |
||
| 53 | 53 | */ |
| 54 | 54 | public function getData() |
| 55 | 55 | { |
| 56 | - return ['fields' => $this->validator->getMessageBag()->toArray()]; |
|
| 56 | + return [ 'fields' => $this->validator->getMessageBag()->toArray() ]; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | \ No newline at end of file |
@@ -34,9 +34,9 @@ |
||
| 34 | 34 | * |
| 35 | 35 | * @param mixed $message |
| 36 | 36 | */ |
| 37 | - public function __construct($message = null) |
|
| 37 | + public function __construct( $message = null ) |
|
| 38 | 38 | { |
| 39 | - parent::__construct($this->statusCode, $message); |
|
| 39 | + parent::__construct( $this->statusCode, $message ); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | * @param \Flugg\Responder\Http\ErrorResponseBuilder $errorResponse |
| 38 | 38 | * @param \Flugg\Responder\Http\SuccessResponseBuilder $successResponse |
| 39 | 39 | */ |
| 40 | - public function __construct(SuccessResponseBuilder $successResponse, ErrorResponseBuilder $errorResponse) |
|
| 40 | + public function __construct( SuccessResponseBuilder $successResponse, ErrorResponseBuilder $errorResponse ) |
|
| 41 | 41 | { |
| 42 | 42 | $this->successResponse = $successResponse; |
| 43 | 43 | $this->errorResponse = $errorResponse; |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | * @param mixed $message |
| 52 | 52 | * @return \Illuminate\Http\JsonResponse |
| 53 | 53 | */ |
| 54 | - public function error(string $errorCode = null, int $statusCode = null, $message = null):JsonResponse |
|
| 54 | + public function error( string $errorCode = null, int $statusCode = null, $message = null ):JsonResponse |
|
| 55 | 55 | { |
| 56 | - return $this->errorResponse->setError($errorCode, $message)->respond($statusCode); |
|
| 56 | + return $this->errorResponse->setError( $errorCode, $message )->respond( $statusCode ); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -64,17 +64,17 @@ discard block |
||
| 64 | 64 | * @param array $meta |
| 65 | 65 | * @return \Illuminate\Http\JsonResponse |
| 66 | 66 | */ |
| 67 | - public function success($data = null, $statusCode = null, array $meta = []):JsonResponse |
|
| 67 | + public function success( $data = null, $statusCode = null, array $meta = [ ] ):JsonResponse |
|
| 68 | 68 | { |
| 69 | - if (is_integer($data)) { |
|
| 70 | - list($data, $statusCode, $meta) = [null, $data, is_array($statusCode) ? $statusCode : []]; |
|
| 69 | + if ( is_integer( $data ) ) { |
|
| 70 | + list($data, $statusCode, $meta) = [ null, $data, is_array( $statusCode ) ? $statusCode : [ ] ]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - if (is_array($statusCode)) { |
|
| 74 | - list($statusCode, $meta) = [200, $statusCode]; |
|
| 73 | + if ( is_array( $statusCode ) ) { |
|
| 74 | + list($statusCode, $meta) = [ 200, $statusCode ]; |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | - return $this->successResponse->transform($data)->addMeta($meta)->respond($statusCode); |
|
| 77 | + return $this->successResponse->transform( $data )->addMeta( $meta )->respond( $statusCode ); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
@@ -84,8 +84,8 @@ discard block |
||
| 84 | 84 | * @param callable|string|null $transformer |
| 85 | 85 | * @return \Flugg\Responder\Http\SuccessResponseBuilder |
| 86 | 86 | */ |
| 87 | - public function transform($data = null, $transformer = null):SuccessResponseBuilder |
|
| 87 | + public function transform( $data = null, $transformer = null ):SuccessResponseBuilder |
|
| 88 | 88 | { |
| 89 | - return $this->successResponse->transform($data, $transformer); |
|
| 89 | + return $this->successResponse->transform( $data, $transformer ); |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | \ No newline at end of file |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | * @param string $key |
| 39 | 39 | * @return bool |
| 40 | 40 | */ |
| 41 | - public function relationLoaded($key); |
|
| 41 | + public function relationLoaded( $key ); |
|
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | 44 | * Convert the model instance to an array. |
@@ -22,10 +22,10 @@ discard block |
||
| 22 | 22 | * @param int $status |
| 23 | 23 | * @return $this |
| 24 | 24 | */ |
| 25 | - protected function seeSuccess($data = null, $status = 200) |
|
| 25 | + protected function seeSuccess( $data = null, $status = 200 ) |
|
| 26 | 26 | { |
| 27 | - $response = $this->seeSuccessResponse($data, $status); |
|
| 28 | - $this->seeSuccessData($response->getData(true)['data']); |
|
| 27 | + $response = $this->seeSuccessResponse( $data, $status ); |
|
| 28 | + $this->seeSuccessData( $response->getData( true )[ 'data' ] ); |
|
| 29 | 29 | |
| 30 | 30 | return $this; |
| 31 | 31 | } |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | * @param int $status |
| 38 | 38 | * @return $this |
| 39 | 39 | */ |
| 40 | - protected function seeSuccessEquals($data = null, $status = 200) |
|
| 40 | + protected function seeSuccessEquals( $data = null, $status = 200 ) |
|
| 41 | 41 | { |
| 42 | - $response = $this->seeSuccessResponse($data, $status); |
|
| 43 | - $this->seeJsonEquals($response->getData(true)); |
|
| 42 | + $response = $this->seeSuccessResponse( $data, $status ); |
|
| 43 | + $this->seeJsonEquals( $response->getData( true ) ); |
|
| 44 | 44 | |
| 45 | 45 | return $this; |
| 46 | 46 | } |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | * @param mixed $data |
| 52 | 52 | * @return $this |
| 53 | 53 | */ |
| 54 | - protected function seeSuccessStructure($data = null) |
|
| 54 | + protected function seeSuccessStructure( $data = null ) |
|
| 55 | 55 | { |
| 56 | - $this->seeJsonStructure([ |
|
| 56 | + $this->seeJsonStructure( [ |
|
| 57 | 57 | 'data' => $data |
| 58 | - ]); |
|
| 58 | + ] ); |
|
| 59 | 59 | |
| 60 | 60 | return $this; |
| 61 | 61 | } |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | * @param int $status |
| 68 | 68 | * @return JsonResponse |
| 69 | 69 | */ |
| 70 | - protected function seeSuccessResponse($data = null, $status = 200):JsonResponse |
|
| 70 | + protected function seeSuccessResponse( $data = null, $status = 200 ):JsonResponse |
|
| 71 | 71 | { |
| 72 | - $response = app(Responder::class)->success($data, $status); |
|
| 72 | + $response = app( Responder::class )->success( $data, $status ); |
|
| 73 | 73 | |
| 74 | - $this->seeStatusCode($response->getStatusCode())->seeJson([ |
|
| 74 | + $this->seeStatusCode( $response->getStatusCode() )->seeJson( [ |
|
| 75 | 75 | 'success' => true, |
| 76 | 76 | 'status' => $response->getStatusCode() |
| 77 | - ])->seeJsonStructure(['data']); |
|
| 77 | + ] )->seeJsonStructure( [ 'data' ] ); |
|
| 78 | 78 | |
| 79 | 79 | return $response; |
| 80 | 80 | } |
@@ -85,13 +85,13 @@ discard block |
||
| 85 | 85 | * @param mixed $data |
| 86 | 86 | * @return $this |
| 87 | 87 | */ |
| 88 | - protected function seeSuccessData($data = null) |
|
| 88 | + protected function seeSuccessData( $data = null ) |
|
| 89 | 89 | { |
| 90 | - collect($data)->each(function ($value, $key) { |
|
| 91 | - if (is_array($value)) { |
|
| 92 | - $this->seeSuccessData($value); |
|
| 90 | + collect( $data )->each( function ( $value, $key ) { |
|
| 91 | + if ( is_array( $value ) ) { |
|
| 92 | + $this->seeSuccessData( $value ); |
|
| 93 | 93 | } else { |
| 94 | - $this->seeJson([$key => $value]); |
|
| 94 | + $this->seeJson( [ $key => $value ] ); |
|
| 95 | 95 | } |
| 96 | 96 | }); |
| 97 | 97 | |
@@ -104,20 +104,20 @@ discard block |
||
| 104 | 104 | * @param string|array $attributes |
| 105 | 105 | * @return array |
| 106 | 106 | */ |
| 107 | - protected function getSuccessData($attributes = null) |
|
| 107 | + protected function getSuccessData( $attributes = null ) |
|
| 108 | 108 | { |
| 109 | - $rawData = $this->decodeResponseJson()['data']; |
|
| 109 | + $rawData = $this->decodeResponseJson()[ 'data' ]; |
|
| 110 | 110 | |
| 111 | - if (is_null($attributes)) { |
|
| 111 | + if ( is_null( $attributes ) ) { |
|
| 112 | 112 | return $rawData; |
| 113 | - } elseif (is_string($attributes)) { |
|
| 114 | - return array_get($rawData, $attributes); |
|
| 113 | + } elseif ( is_string( $attributes ) ) { |
|
| 114 | + return array_get( $rawData, $attributes ); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $data = []; |
|
| 117 | + $data = [ ]; |
|
| 118 | 118 | |
| 119 | - foreach ($attributes as $attribute) { |
|
| 120 | - $data[] = array_get($rawData, $attribute); |
|
| 119 | + foreach ( $attributes as $attribute ) { |
|
| 120 | + $data[ ] = array_get( $rawData, $attribute ); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | return $data; |
@@ -130,25 +130,25 @@ discard block |
||
| 130 | 130 | * @param int|null $status |
| 131 | 131 | * @return $this |
| 132 | 132 | */ |
| 133 | - protected function seeError(string $error, int $status = null) |
|
| 133 | + protected function seeError( string $error, int $status = null ) |
|
| 134 | 134 | { |
| 135 | - if (! is_null($status)) { |
|
| 136 | - $this->seeStatusCode($status); |
|
| 135 | + if ( ! is_null( $status ) ) { |
|
| 136 | + $this->seeStatusCode( $status ); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - if ($this->app->config->get('responder.status_code')) { |
|
| 140 | - $this->seeJson([ |
|
| 139 | + if ( $this->app->config->get( 'responder.status_code' ) ) { |
|
| 140 | + $this->seeJson( [ |
|
| 141 | 141 | 'status' => $status |
| 142 | - ]); |
|
| 142 | + ] ); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return $this->seeJson([ |
|
| 145 | + return $this->seeJson( [ |
|
| 146 | 146 | 'success' => false |
| 147 | - ])->seeJsonSubset([ |
|
| 147 | + ] )->seeJsonSubset( [ |
|
| 148 | 148 | 'error' => [ |
| 149 | 149 | 'code' => $error |
| 150 | 150 | ] |
| 151 | - ]); |
|
| 151 | + ] ); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | * @param int $status |
| 158 | 158 | * @return $this |
| 159 | 159 | */ |
| 160 | - abstract protected function seeStatusCode($status); |
|
| 160 | + abstract protected function seeStatusCode( $status ); |
|
| 161 | 161 | |
| 162 | 162 | /** |
| 163 | 163 | * Assert that the response contains JSON. |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param bool $negate |
| 167 | 167 | * @return $this |
| 168 | 168 | */ |
| 169 | - abstract public function seeJson(array $data = null, $negate = false); |
|
| 169 | + abstract public function seeJson( array $data = null, $negate = false ); |
|
| 170 | 170 | |
| 171 | 171 | /** |
| 172 | 172 | * Assert that the JSON response has a given structure. |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param array|null $responseData |
| 176 | 176 | * @return $this |
| 177 | 177 | */ |
| 178 | - abstract public function seeJsonStructure(array $structure = null, $responseData = null); |
|
| 178 | + abstract public function seeJsonStructure( array $structure = null, $responseData = null ); |
|
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | 181 | * Assert that the response is a superset of the given JSON. |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | * @param array $data |
| 184 | 184 | * @return $this |
| 185 | 185 | */ |
| 186 | - abstract protected function seeJsonSubset(array $data); |
|
| 186 | + abstract protected function seeJsonSubset( array $data ); |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * Assert that the response contains an exact JSON array. |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @param array $data |
| 192 | 192 | * @return $this |
| 193 | 193 | */ |
| 194 | - abstract public function seeJsonEquals(array $data); |
|
| 194 | + abstract public function seeJsonEquals( array $data ); |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * Validate and return the decoded response JSON. |