Issues (3)

src/JsonSchemaRequest.php (1 issue)

Labels
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
It seems like $this->container->call(array($this, 'schema')) can also be of type callable; however, parameter $schema of Webtools\JsonSchemaReque...alidator::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
                /** @scrutinizer ignore-type */ $this->container->call([$this, 'schema']),
Loading history...
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();
49
    }
50
}
51