Test Failed
Push — master ( 9fb3c6...d8fcf0 )
by Daniel
13:23 queued 08:16
created

OpenApiDecorator   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 37
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A OpenApiFactory::__construct() 0 3 1
A OpenApiFactory::__invoke() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[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
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\OpenApi;
15
16
use ApiPlatform\Core\OpenApi\Factory\OpenApiFactoryInterface;
17
use ApiPlatform\Core\OpenApi\OpenApi;
18
use PackageVersions\Versions;
19
use Silverback\ApiComponentsBundle\Entity\Component\Form;
20
use Silverback\ApiComponentsBundle\Entity\Core\AbstractComponent;
21
22
/**
23
 * @author Daniel West <[email protected]>
24
 */
25
class OpenApiFactory implements OpenApiFactoryInterface
26
{
27
    private $decorated;
28
29
    public function __construct(OpenApiFactoryInterface $decorated)
30
    {
31
        $this->decorated = $decorated;
32
    }
33
34
    public function __invoke(array $context = []): OpenApi
35
    {
36
        $openApi = $this->decorated->__invoke($context);
37
        $version = sprintf('%s (%s)', $openApi->getInfo()->getVersion(), Versions::getVersion('silverbackis/api-components-bundle'));
38
39
        return $openApi->withInfo($openApi->getInfo()->withVersion($version));
40
//        $components = $openApi->getComponents();
41
//        $classes = [];
42
//        $unsupported = [Form::class, AbstractComponent::class];
43
//        foreach ($components as $className => $component) {
44
//            if (\in_array($className, $unsupported, true)) {
45
//                continue;
46
//            }
47
//            $classes[] = $className;
48
//        }
49
//        $newResourceNameCollection = new ResourceNameCollection($classes);
50
    }
51
}
52