Passed
Pull Request — main (#77)
by
unknown
03:28
created

JsonFormRequest::failedValidation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 5
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 8
rs 10
1
<?php
2
3
namespace CSlant\Blog\Api\Http\Requests;
4
5
use Illuminate\Contracts\Validation\Validator;
6
use Illuminate\Foundation\Http\FormRequest;
7
use Illuminate\Http\Exceptions\HttpResponseException;
8
use Illuminate\Http\Response;
9
10
class JsonFormRequest extends FormRequest
11
{
12
    /**
13
     * @param Validator $validator
14
     */
15
    protected function failedValidation(Validator $validator)
16
    {
17
        $response = response()->json([
18
            'status' => Response::HTTP_BAD_REQUEST,
19
            'errors' => $validator->errors(),
20
        ], Response::HTTP_BAD_REQUEST);
21
22
        throw new HttpResponseException($response);
23
    }
24
}
25