ApiRequest::failedValidation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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