Completed
Push — master ( 1fd225...0ced52 )
by Markus
11s queued 10s
created

ValidatorFactory   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

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

1 Method

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