for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types = 1);
namespace RamosHenrique\JsonSchemaValidator;
use Exception;
use Illuminate\Support\Facades\Validator as BaseValidator;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Illuminate\Validation\ValidationException;
class ServiceProvider extends BaseServiceProvider
{
public function boot()
$this->publishes(
[
__DIR__.'/../config/json_schema_validator.php' => config_path('json_schema_validator.php'),
],
'json_schema_validator'
);
BaseValidator::extend('json_schema_validator', static function ($attribute, $value, $parameters, $validator) {
$validator
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
BaseValidator::extend('json_schema_validator', static function ($attribute, $value, $parameters, /** @scrutinizer ignore-unused */ $validator) {
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
if (count($parameters) != 1) {
throw ValidationException::withMessages([
'json_schema_validator' => JsonSchemaValidatorException::INVALID_PARAMETERS_QUANTITY,
]);
}
$filePath = config('json_schema_validator.storage_path') . '/' . $parameters[0];
try {
$JsonValidate = new JsonSchemaValidator();
$JsonValidate->setSchema($filePath);
$JsonValidate->setData($value);
return $JsonValidate->validate();
} catch (Exception $e) {
'json_schema_validator' => $e->getMessage(),
});
/**
* Make config publishment optional by merging the config from the package.
*
* @return void
*/
public function register()
$this->mergeConfigFrom(
__DIR__.'/../config/json_schema_validator.php',
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.