FileGetContents   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setBasePath() 0 4 1
A retrieve() 0 8 1
1
<?php
2
3
namespace Realshadow\RequestDeserializer\JsonSchema\Uri\Retrievers;
4
5
use JsonSchema\Uri\Retrievers\FileGetContents as OriginalFileGetContents;
6
use JsonSchema\Uri\Retrievers\UriRetrieverInterface;
7
8
9
/**
10
 * Override of the originle retriever so we can look for nested and/or inherited schemas on disk in specified base path
11
 *
12
 * @package Realshadow\RequestDeserializer\JsonSchema\Uri\Retrievers
13
 * @author Lukáš Homza <[email protected]>
14
 */
15
class FileGetContents extends OriginalFileGetContents implements UriRetrieverInterface
16
{
17
18
    /**
19
     * @var string $basePath
20
     */
21
    private $basePath;
22
23
    /**
24
     * @param string $basePath
25
     */
26
    public function setBasePath($basePath)
27
    {
28
        $this->basePath = $basePath;
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     * @see \JsonSchema\Uri\Retrievers\UriRetrieverInterface::retrieve()
34
     */
35
    public function retrieve($uri)
36
    {
37
        $scheme = parse_url($uri)['scheme'] . '://';
38
39
        $uri = str_replace($scheme, $scheme . $this->basePath, $uri);
40
41
        return parent::retrieve($uri);
42
    }
43
44
}
45