ValidatorFactory   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jellyfish\JsonSchemaOpis;
6
7
use Jellyfish\JsonSchema\ValidatorFactoryInterface;
8
use Jellyfish\JsonSchema\ValidatorInterface;
9
use Opis\JsonSchema\Schema as OpisSchema;
10
use Opis\JsonSchema\Validator as OpisValidator;
11
12
class ValidatorFactory implements ValidatorFactoryInterface
13
{
14
    /**
15
     * @param string $schema
16
     *
17
     * @return \Jellyfish\JsonSchema\ValidatorInterface
18
     */
19
    public function create(string $schema): ValidatorInterface
20
    {
21
        $schema = new OpisSchema(\json_decode($schema));
22
        $validator = new OpisValidator();
23
24
        return new Validator($validator, $schema);
25
    }
26
}
27