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

ValidatorFactory::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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