Completed
Push — feature/update-json-schema-dep ( f753ff...de5535 )
by Narcotic
02:40
created

SchemaFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 2
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 28
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createSchema() 0 4 1
1
<?php
2
/**
3
 * SchemaFactory class file
4
 */
5
namespace Graviton\JsonSchemaBundle\Schema;
6
7
use JsonSchema\RefResolver;
8
9
/**
10
 * JSON schema factory
11
 *
12
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class SchemaFactory
17
{
18
    /**
19
     * @var RefResolver
20
     */
21
    private $refResolver;
22
23
    /**
24
     * Constructor
25
     *
26
     * @param RefResolver $resolver Ref resolver
27
     */
28 1
    public function __construct(RefResolver $resolver)
29
    {
30 1
        $this->refResolver = $resolver;
31 1
    }
32
33
    /**
34
     * Create JSON schema
35
     *
36
     * @param string $uri Schema URI
37
     * @return \stdClass
38
     */
39 1
    public function createSchema($uri)
40
    {
41 1
        return $this->refResolver->resolve($uri);
42
    }
43
}
44