SwaggerFormatter::deriveParameters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the "elao/api-resources-metadata" package.
5
 *
6
 * Copyright (C) 2016 Elao
7
 *
8
 * @author Elao <[email protected]>
9
 */
10
11
namespace Elao\ApiResourcesMetadata\Bridge\Nelmio\ApiDoc\Swagger;
12
13
use Elao\ApiResourcesMetadata\Resource\Factory\ResourceMetadataFactory;
14
use Elao\ApiResourcesMetadata\Resource\ResourceIndex;
15
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
16
use Nelmio\ApiDocBundle\Formatter\SwaggerFormatter as NelmioSwaggerFormatter;
17
18
/**
19
 * A special decorator allowing to hook on model name generation
20
 * and automatically use api resource shortName if available
21
 */
22
class SwaggerFormatter extends NelmioSwaggerFormatter
23
{
24
    /** @var NelmioSwaggerFormatter */
25
    private $originalFormatter;
26
27
    public function __construct(
28
        NelmioSwaggerFormatter $originalFormatter,
29
        string $namingStategy,
30
        ResourceIndex $resourceIndex,
31
        ResourceMetadataFactory $metadataFactory
32
    ) {
33
        $this->originalFormatter = $originalFormatter;
34
35
        $this->originalFormatter->modelRegistry = new ModelRegistry(
36
            $namingStategy,
37
            $resourceIndex,
38
            $metadataFactory
39
        );
40
    }
41
42
    public function setAuthenticationConfig(array $config)
43
    {
44
        $this->originalFormatter->setAuthenticationConfig($config);
45
    }
46
47
    public function format(array $collection, $resource = null)
48
    {
49
        return $this->originalFormatter->format($collection, $resource);
50
    }
51
52
    public function produceResourceListing(array $collection)
53
    {
54
        return $this->originalFormatter->produceResourceListing($collection);
55
    }
56
57
    protected function getAuthorizations()
58
    {
59
        return $this->originalFormatter->getAuthorizations();
60
    }
61
62
    protected function getInfo()
63
    {
64
        return $this->originalFormatter->getInfo();
65
    }
66
67
    public function formatOne(ApiDoc $annotation)
68
    {
69
        $this->originalFormatter->formatOne($annotation);
70
    }
71
72
    protected function produceApiDeclaration(array $collection, $resource)
73
    {
74
        return $this->originalFormatter->produceApiDeclaration($collection, $resource);
75
    }
76
77
    protected function normalizeResourcePath($path)
78
    {
79
        return $this->originalFormatter->normalizeResourcePath($path);
80
    }
81
82
    public function setBasePath($path)
83
    {
84
        $this->originalFormatter->setBasePath($path);
85
    }
86
87
    protected function deriveQueryParameters(array $input)
88
    {
89
        return $this->originalFormatter->deriveQueryParameters($input);
90
    }
91
92
    protected function deriveParameters(array $input, $paramType = 'form')
93
    {
94
        return $this->originalFormatter->deriveParameters($input, $paramType);
95
    }
96
97
    public function registerModel($className, array $parameters = null, $description = '')
98
    {
99
        return $this->originalFormatter->registerModel($className, $parameters, $description);
100
    }
101
102
    public function setSwaggerVersion($swaggerVersion)
103
    {
104
        $this->originalFormatter->setSwaggerVersion($swaggerVersion);
105
    }
106
107
    public function setApiVersion($apiVersion)
108
    {
109
        $this->originalFormatter->setApiVersion($apiVersion);
110
    }
111
112
    public function setInfo($info)
113
    {
114
        $this->originalFormatter->setInfo($info);
115
    }
116
117
    protected function stripBasePath($basePath)
118
    {
119
        return $this->originalFormatter->stripBasePath($basePath);
120
    }
121
122
    protected function generateNickname($method, $resource)
123
    {
124
        return $this->originalFormatter->generateNickname($method, $resource);
125
    }
126
}
127