1 | <?php |
||||
2 | |||||
3 | namespace Webtools\JsonSchemaRequest; |
||||
4 | |||||
5 | use Illuminate\Contracts\Container\Container; |
||||
6 | use Illuminate\Contracts\Validation\ValidatesWhenResolved; |
||||
7 | use Illuminate\Contracts\Validation\Validator as ValidatorContract; |
||||
8 | use Illuminate\Http\Request; |
||||
9 | use Illuminate\Validation\ValidatesWhenResolvedTrait; |
||||
10 | use Webtools\JsonSchemaRequest\Exceptions\ValidationException; |
||||
11 | use Webtools\JsonSchemaRequest\Validation\JsonSchemaValidator; |
||||
12 | |||||
13 | class JsonSchemaRequest extends Request implements ValidatesWhenResolved |
||||
14 | { |
||||
15 | use ValidatesWhenResolvedTrait; |
||||
16 | |||||
17 | protected Container $container; |
||||
18 | |||||
19 | protected ?ValidatorContract $validator = null; |
||||
20 | |||||
21 | 2 | public function getValidatorInstance() |
|||
22 | { |
||||
23 | 2 | if (!$this->validator) { |
|||
24 | 2 | $this->validator = new JsonSchemaValidator( |
|||
25 | 2 | $this->container->make(\JsonSchema\Validator::class), |
|||
26 | 2 | $this->container->call([$this, 'schema']), |
|||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
27 | 2 | $this->json()->all(), |
|||
28 | ); |
||||
29 | } |
||||
30 | |||||
31 | 2 | return $this->validator; |
|||
32 | } |
||||
33 | |||||
34 | 2 | public function setContainer(Container $container) |
|||
35 | { |
||||
36 | 2 | $this->container = $container; |
|||
37 | |||||
38 | 2 | return $this; |
|||
39 | } |
||||
40 | |||||
41 | 1 | public function failedValidation(JsonSchemaValidator $validator) |
|||
42 | { |
||||
43 | 1 | throw new ValidationException($validator); |
|||
44 | } |
||||
45 | |||||
46 | 1 | public function validated() |
|||
47 | { |
||||
48 | 1 | return $this->validator->validated(); |
|||
0 ignored issues
–
show
The method
validated() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
49 | } |
||||
50 | } |
||||
51 |