Passed
Pull Request — master (#661)
by
unknown
10:13
created

JsonValidator::isValid()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 8
rs 10
1
<?php
2
3
namespace OldSound\RabbitMqBundle\RabbitMq;
4
5
use Swaggest\JsonSchema\Schema;
6
use Swaggest\JsonSchema\Exception;
7
8
9
class JsonValidator implements ValidatorInterface
10
{
11
    public function isValid($msg, $validatorFile)
12
    {
13
        try{
14
            $schema = Schema::import(json_decode(file_get_contents($validatorFile, true)));
15
            $schema->in($msg);
16
            return true;
17
        }catch (Exception $e){
18
            return false;
19
        }
20
    }
21
}