Passed
Push — master ( 5fcd6e...b951b3 )
by Marcel
03:18
created

Validator::validate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace UMA\JsonRpc\Internal;
6
7
use Opis\JsonSchema\Validator as OpisValidator;
8
9
class Validator
10
{
11
    /**
12
     * @param \stdClass $schema The schema to check against the given data
13
     * @param mixed     $data   The data to validate (MUST be decoded JSON data)
14
     *
15
     * @return bool Whether $data conforms to $schema or not
16
     */
17 16
    public static function validate(\stdClass $schema, $data): bool
18
    {
19 16
        \assert(false !== \json_encode($data));
20
21 16
        return (new OpisValidator)
22 16
            ->dataValidation($data, $schema)
23 16
            ->isValid();
24
    }
25
}
26