Conditions | 3 |
Paths | 1 |
Total Lines | 28 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php declare(strict_types = 1); |
||
13 | public function boot() |
||
14 | { |
||
15 | $this->publishes( |
||
16 | [ |
||
17 | __DIR__.'/../config/json_schema_validator.php' => config_path('json_schema_validator.php'), |
||
18 | ], |
||
19 | 'json_schema_validator' |
||
20 | ); |
||
21 | |||
22 | BaseValidator::extend('json_schema_validator', static function ($attribute, $value, $parameters, $validator) { |
||
|
|||
23 | if (count($parameters) != 1) { |
||
24 | throw ValidationException::withMessages([ |
||
25 | 'json_schema_validator' => JsonSchemaValidatorException::INVALID_PARAMETERS_QUANTITY, |
||
26 | ]); |
||
27 | } |
||
28 | |||
29 | $filePath = config('json_schema_validator.storage_path') . '/' . $parameters[0]; |
||
30 | |||
31 | try { |
||
32 | $JsonValidate = new JsonSchemaValidator(); |
||
33 | |||
34 | $JsonValidate->setSchema($filePath); |
||
35 | $JsonValidate->setData($value); |
||
36 | |||
37 | return $JsonValidate->validate(); |
||
38 | } catch (Exception $e) { |
||
39 | throw ValidationException::withMessages([ |
||
40 | 'json_schema_validator' => $e->getMessage(), |
||
41 | ]); |
||
59 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.