Completed
Push — master ( 9e1950...9b3371 )
by Veaceslav
02:29 queued 48s
created

SchemaFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of Rebilly.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @see http://rebilly.com
9
 */
10
11
namespace Rebilly\OpenAPI;
12
13
use JsonSchema\SchemaStorage;
14
use JsonSchema\Uri\UriResolver;
15
use JsonSchema\Uri\UriRetriever;
16
17
final class SchemaFactory
18
{
19 9
    public function create(string $uri)
20
    {
21 9
        if (strpos($uri, '//') === false) {
22 9
            $uri = "file://{$uri}";
23
        }
24
25 9
        $schemaStorage = new SchemaStorage(new UriRetriever(), new UriResolver());
26 9
        $schemaStorage->addSchema($uri);
27
28 9
        return new Schema($schemaStorage->getSchema($uri));
29
    }
30
}
31