EntityDefinitionValidator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the CRUDlex package.
5
 *
6
 * (c) Philip Lehmann-Böhm <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CRUDlex;
13
14
use RomaricDrigon\MetaYaml\MetaYaml;
15
use RomaricDrigon\MetaYaml\Loader\YamlLoader;
16
17
/**
18
 * An entity definition validator using the romaricdrigon/MetaYaml validator with the
19
 * given definitionSchema.yml.
20
 */
21
class EntityDefinitionValidator implements EntityDefinitionValidatorInterface
22
{
23
24
    /**
25
     * {@inheritdoc}
26
     */
27 79
    public function validate(array $data)
28
    {
29 79
        $loader        = new YamlLoader();
30 79
        $schemaContent = $loader->loadFromFile(__DIR__.'/../definitionSchema.yml');
31 79
        $schema        = new MetaYaml($schemaContent);
32
        try {
33 79
            $schema->validate($data);
34 1
        } catch (\Exception $e) {
35 1
            throw new \LogicException($e->getMessage(), $e->getCode(), $e);
36
        }
37 79
    }
38
39
}
40