Completed
Push — master ( 83fca8...0d9c6e )
by Andrii
10:43
created

src/validators/JsonValidator.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace hiapi\validators;
4
5
use yii\base\InvalidArgumentException;
6
use yii\helpers\Json;
7
use yii\validators\Validator;
8
9
/**
10
 * Class JsonValidator
11
 *
12
 * @author Dmytro Naumenko <[email protected]>
13
 */
14
class JsonValidator extends Validator
15
{
16
    public function __construct(array $config = [])
17
    {
18
        parent::__construct($config);
19
20
        $this->message = '{attribute} must be a valid JSON';
21
    }
22
23
    protected function validateValue($value)
24
    {
25
        try {
26
            Json::decode($value);
27
        } catch (InvalidArgumentException $e) {
0 ignored issues
show
The class yii\base\InvalidArgumentException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
28
            return [$this->message, []];
29
        }
30
    }
31
}
32