Generator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 22
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 3
A generate() 0 6 1
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