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

Validator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 2
dl 0
loc 17
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 8 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