RawDocProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 39
ccs 9
cts 9
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDoc() 0 4 1
A __construct() 0 6 1
A supports() 0 3 1
1
<?php
2
namespace Yoanm\SymfonyJsonRpcHttpServerDoc\Provider;
3
4
use Yoanm\JsonRpcServerDoc\Infra\Normalizer\HttpServerDocNormalizer;
5
use Yoanm\SymfonyJsonRpcHttpServerDoc\Creator\HttpServerDocCreator;
6
7
/**
8
 * Class RawDocProvider
9
 */
10
class RawDocProvider implements DocProviderInterface
11
{
12
    /** @var HttpServerDocCreator */
13
    private $httpServerDocCreator;
14
    /** @var HttpServerDocNormalizer */
15
    private $serverDocNormalizer;
16
17
    const SUPPORTED_FILENAME = 'raw.json';
18
19
    /**
20
     * @param HttpServerDocCreator    $HttpServerDocCreator
21
     * @param HttpServerDocNormalizer $serverDocNormalizer
22
     */
23 5
    public function __construct(
24
        HttpServerDocCreator $HttpServerDocCreator,
25
        HttpServerDocNormalizer $serverDocNormalizer
26
    ) {
27 5
        $this->httpServerDocCreator = $HttpServerDocCreator;
28 5
        $this->serverDocNormalizer = $serverDocNormalizer;
29
    }
30
31
    /**
32
     * @param string|null $host
33
     *
34
     * @return array
35
     */
36 4
    public function getDoc($host = null) : array
37
    {
38 4
        return $this->serverDocNormalizer->normalize(
39 4
            $this->httpServerDocCreator->create($host)
40 4
        );
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46 4
    public function supports($filename, $host = null) : bool
47
    {
48 4
        return self::SUPPORTED_FILENAME === $filename;
49
    }
50
}
51