Passed
Pull Request — dev (#147)
by Marcin
03:00
created

ValidationExceptionHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 2
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace MarcinOrlowski\ResponseBuilder\ExceptionHandlers;
5
6
use MarcinOrlowski\ResponseBuilder\BaseApiCodes;
7
use MarcinOrlowski\ResponseBuilder\Contracts\ExceptionHandlerContract;
8
use MarcinOrlowski\ResponseBuilder\ResponseBuilder;
9
use Symfony\Component\HttpFoundation\Response as HttpResponse;
10
11
/**
12
 * Laravel API Response Builder
13
 *
14
 * @package   MarcinOrlowski\ResponseBuilder
15
 *
16
 * @author    Marcin Orlowski <mail (#) marcinOrlowski (.) com>
17
 * @copyright 2016-2020 Marcin Orlowski
18
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
19
 * @link      https://github.com/MarcinOrlowski/laravel-api-response-builder
20
 */
21
final class ValidationExceptionHandler implements ExceptionHandlerContract
22
{
23
	public function handle(array $user_config, \Exception $ex): ?array
24
	{
25
		return [
26
			ResponseBuilder::KEY_API_CODE  => BaseApiCodes::EX_VALIDATION_EXCEPTION(),
0 ignored issues
show
Deprecated Code introduced by
The function MarcinOrlowski\ResponseB..._VALIDATION_EXCEPTION() has been deprecated: Configure Exception Handler to use your own API code. This method will be removed in v8. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

26
			ResponseBuilder::KEY_API_CODE  => /** @scrutinizer ignore-deprecated */ BaseApiCodes::EX_VALIDATION_EXCEPTION(),

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
27
			ResponseBuilder::KEY_HTTP_CODE => HttpResponse::HTTP_UNPROCESSABLE_ENTITY,
28
		];
29
	}
30
}
31