Generator::generate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SwaggerMiddleware;
4
5
class Generator
6
{
7
    private $config;
8
9 15
    public function __construct(array $config)
10
    {
11 15
        if (empty($config['scan']['paths']) || !is_array($config['scan']['paths'])) {
12 3
            throw new \InvalidArgumentException(
13 3
                'Invalid scan \'paths\' config option. Please provide at least one path.'
14
            );
15
        }
16
17 12
        $this->config = $config;
18 12
    }
19
20 6
    public function generate(array $customConfig = null): \Swagger\Annotations\Swagger
21
    {
22 6
        $config = $customConfig ?? $this->config;
23
24 6
        return \Swagger\scan($config['scan']['paths'], $config['scan']['options'] ?? []);
25
    }
26
}
27