ValidatorFactory::create()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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