Completed
Push — master ( 6343d0...45320b )
by Bernhard
06:10
created

LocalUriRetriever::retrieve()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 5.1576

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
ccs 7
cts 12
cp 0.5833
rs 9.0534
cc 4
eloc 14
nc 4
nop 1
crap 5.1576
1
<?php
2
3
/*
4
 * This file is part of the webmozart/json package.
5
 *
6
 * (c) Bernhard Schussek <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Puli\Manager\Json;
13
14
use JsonSchema\Uri\Retrievers\FileGetContents;
15
use Webmozart\PathUtil\Path;
16
17
/**
18
 * @since  1.0
19
 *
20
 * @author Bernhard Schussek <[email protected]>
21
 */
22
class LocalUriRetriever extends FileGetContents
23
{
24
    /**
25
     * @var string
26
     */
27
    private $baseDir;
28
29 26
    public function __construct()
30
    {
31 26
        $this->baseDir = 'file://'.Path::canonicalize(__DIR__.'/../../res/schema');
32 26
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 26
    public function retrieve($uri)
38
    {
39
        switch ($uri) {
40 26
            case 'http://puli.io/schema/1.0/manager/module':
41 26
                $uri = $this->baseDir.'/module-schema-1.0.json';
42 26
                break;
43
44
            case 'http://puli.io/schema/2.0/manager/module':
45 26
                $uri = $this->baseDir.'/module-schema-2.0.json';
46 26
                break;
47
48
            case 'http://puli.io/schema/1.0/manager/dependencies':
49
                $uri = $this->baseDir.'/dependencies-schema-1.0.json';
50
                break;
51
52
            default:
53
                break;
54
        }
55
56 26
        return parent::retrieve($uri);
57
    }
58
}
59