ApiRequest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 12
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A failedValidation() 0 6 1
1
<?php
2
3
namespace Lbil\LaravelGenerator\Http\Requests;
4
5
use Illuminate\Contracts\Validation\Validator;
6
use Illuminate\Foundation\Http\FormRequest;
0 ignored issues
show
Bug introduced by
The type Illuminate\Foundation\Http\FormRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Http\Exceptions\HttpResponseException;
8
use Symfony\Component\HttpFoundation\Response as ResponseAlias;
9
10
/**
11
 * Class ApiRequest.
12
 */
13
abstract class ApiRequest extends FormRequest
14
{
15
    /**
16
     * @param  Validator  $validator
17
     * @return void
18
     */
19
    public function failedValidation(Validator $validator): void
20
    {
21
        throw new HttpResponseException(
22
            response()->json([
23
                'message' => $validator->errors()->toArray(),
24
            ], ResponseAlias::HTTP_BAD_REQUEST, [], JSON_UNESCAPED_UNICODE)
25
        );
26
    }
27
}
28