Failed Conditions
Pull Request — release/0.1.0 (#2)
by Yo
03:26
created

RawDocProvider::getDoc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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
    /**
18
     * @param HttpServerDocCreator    $HttpServerDocCreator
19
     * @param HttpServerDocNormalizer $serverDocNormalizer
20
     */
21 2
    public function __construct(
22
        HttpServerDocCreator $HttpServerDocCreator,
23
        HttpServerDocNormalizer $serverDocNormalizer
24
    ) {
25 2
        $this->httpServerDocCreator = $HttpServerDocCreator;
26 2
        $this->serverDocNormalizer = $serverDocNormalizer;
27 2
    }
28
29
    /**
30
     * @param string|null $host
31
     *
32
     * @return array
33
     */
34 1
    public function getDoc($host = null) : array
35
    {
36 1
        return $this->serverDocNormalizer->normalize(
37 1
            $this->httpServerDocCreator->create($host)
38
        );
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function supports($filename, $host = null) : bool
45
    {
46 1
        return 'raw.json' === $filename;
47
    }
48
}
49