@@ -8,6 +8,7 @@ discard block |
||
| 8 | 8 | |
| 9 | 9 | namespace PhpRestfulApiResponse; |
| 10 | 10 | |
| 11 | +use InvalidArgumentException; |
|
| 11 | 12 | use League\Fractal\Manager; |
| 12 | 13 | use League\Fractal\Pagination\Cursor; |
| 13 | 14 | use League\Fractal\Resource\Collection; |
@@ -15,7 +16,6 @@ discard block |
||
| 15 | 16 | use League\Fractal\TransformerAbstract; |
| 16 | 17 | use PhpRestfulApiResponse\Contracts\PhpRestfulApiResponse; |
| 17 | 18 | use Zend\Diactoros\MessageTrait; |
| 18 | -use InvalidArgumentException; |
|
| 19 | 19 | |
| 20 | 20 | class Response implements PhpRestfulApiResponse |
| 21 | 21 | { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| 173 | - * @param $data |
|
| 173 | + * @param Tests\unit\Lib\Book $data |
|
| 174 | 174 | * @param TransformerAbstract|callable $transformer |
| 175 | 175 | * @param int $code |
| 176 | 176 | * @param null $resourceKey |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | - * @param $data |
|
| 197 | + * @param Tests\unit\Lib\Book[] $data |
|
| 198 | 198 | * @param TransformerAbstract|callable $transformer |
| 199 | 199 | * @param int $code |
| 200 | 200 | * @param null $resourceKey |
@@ -228,7 +228,7 @@ discard block |
||
| 228 | 228 | * @param string|array $message |
| 229 | 229 | * @param string $code |
| 230 | 230 | * @param array $headers |
| 231 | - * @return mixed |
|
| 231 | + * @return Response |
|
| 232 | 232 | */ |
| 233 | 233 | public function withError($message, $code, array $headers = []) |
| 234 | 234 | { |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | * |
| 256 | 256 | * @param string $message |
| 257 | 257 | * @param array $headers |
| 258 | - * @return mixed |
|
| 258 | + * @return Response |
|
| 259 | 259 | */ |
| 260 | 260 | public function errorForbidden(string $message = '', array $headers = []) |
| 261 | 261 | { |
@@ -267,7 +267,7 @@ discard block |
||
| 267 | 267 | * |
| 268 | 268 | * @param string $message |
| 269 | 269 | * @param array $headers |
| 270 | - * @return mixed |
|
| 270 | + * @return Response |
|
| 271 | 271 | */ |
| 272 | 272 | public function errorInternalError(string $message = '', array $headers = []) |
| 273 | 273 | { |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | * |
| 280 | 280 | * @param string $message |
| 281 | 281 | * @param array $headers |
| 282 | - * @return mixed |
|
| 282 | + * @return Response |
|
| 283 | 283 | */ |
| 284 | 284 | public function errorNotFound(string $message = '', array $headers = []) |
| 285 | 285 | { |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @param string $message |
| 293 | 293 | * @param array $headers |
| 294 | - * @return mixed |
|
| 294 | + * @return Response |
|
| 295 | 295 | */ |
| 296 | 296 | public function errorUnauthorized(string $message = '', array $headers = []) |
| 297 | 297 | { |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @param array $message |
| 305 | 305 | * @param array $headers |
| 306 | - * @return mixed |
|
| 306 | + * @return Response |
|
| 307 | 307 | */ |
| 308 | 308 | public function errorWrongArgs(array $message, array $headers = []) |
| 309 | 309 | { |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | * |
| 316 | 316 | * @param string $message |
| 317 | 317 | * @param array $headers |
| 318 | - * @return mixed |
|
| 318 | + * @return Response |
|
| 319 | 319 | */ |
| 320 | 320 | public function errorGone(string $message = '', array $headers = []) |
| 321 | 321 | { |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @param string $message |
| 329 | 329 | * @param array $headers |
| 330 | - * @return mixed |
|
| 330 | + * @return Response |
|
| 331 | 331 | */ |
| 332 | 332 | public function errorMethodNotAllowed(string $message = '', array $headers = []) |
| 333 | 333 | { |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @param string $message |
| 341 | 341 | * @param array $headers |
| 342 | - * @return mixed |
|
| 342 | + * @return Response |
|
| 343 | 343 | */ |
| 344 | 344 | public function errorUnwillingToProcess(string $message = '', array $headers = []) |
| 345 | 345 | { |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @param string $message |
| 353 | 353 | * @param array $headers |
| 354 | - * @return mixed |
|
| 354 | + * @return Response |
|
| 355 | 355 | */ |
| 356 | 356 | public function errorUnprocessable(string $message = '', array $headers = []) |
| 357 | 357 | { |
@@ -60,6 +60,9 @@ |
||
| 60 | 60 | $this->assertEquals('{"data":[{"title":"how to be a ninja","author":{"name":"harry","email":"harryosmarsitohang"},"year":2017,"price":100000},{"title":"how to be a mage","author":{"name":"harry","email":"harryosmarsitohang"},"year":2016,"price":500000},{"title":"how to be a samurai","author":{"name":"harry","email":"harryosmarsitohang"},"year":2000,"price":25000}]}', $response->getBody()->__toString()); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | + /** |
|
| 64 | + * @param integer $code |
|
| 65 | + */ |
|
| 63 | 66 | private function withError(Response $response, $code, $message = null) |
| 64 | 67 | { |
| 65 | 68 | $this->assertEquals($code, $response->getStatusCode()); |