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

DefaultExceptionHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace MarcinOrlowski\ResponseBuilder\ExceptionHandlers;
5
6
/**
7
 * Laravel API Response Builder
8
 *
9
 * @package   MarcinOrlowski\ResponseBuilder
10
 *
11
 * @author    Marcin Orlowski <mail (#) marcinOrlowski (.) com>
12
 * @copyright 2016-2020 Marcin Orlowski
13
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
14
 * @link      https://github.com/MarcinOrlowski/laravel-api-response-builder
15
 */
16
17
use MarcinOrlowski\ResponseBuilder\BaseApiCodes;
18
use MarcinOrlowski\ResponseBuilder\Contracts\ExceptionHandlerContract;
19
use MarcinOrlowski\ResponseBuilder\ResponseBuilder;
20
use Symfony\Component\HttpFoundation\Response as HttpResponse;
21
22
final class DefaultExceptionHandler implements ExceptionHandlerContract
23
{
24
	public function handle(array $user_config, \Exception $ex): ?array
25
	{
26
		$defaults = [
27
			ResponseBuilder::KEY_API_CODE  => BaseApiCodes::EX_UNCAUGHT_EXCEPTION(),
0 ignored issues
show
Deprecated Code introduced by
The function MarcinOrlowski\ResponseB...EX_UNCAUGHT_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

27
			ResponseBuilder::KEY_API_CODE  => /** @scrutinizer ignore-deprecated */ BaseApiCodes::EX_UNCAUGHT_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...
28
			ResponseBuilder::KEY_HTTP_CODE => HttpResponse::HTTP_INTERNAL_SERVER_ERROR,
29
		];
30
31
		return \array_replace($defaults, $user_config);
32
	}
33
}
34