Passed
Pull Request — master (#661)
by
unknown
06:27
created

JsonValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 10
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 10
rs 10
wmc 2

1 Method

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