Completed
Push — master ( 00d376...cc54a0 )
by Veaceslav
01:15
created

ParameterCollectionBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addParameters() 0 8 2
A createParameterCollection() 0 11 1
A getParameters() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9
final class ParameterCollectionBuilder implements Objects\ParameterCollectionFactory
10
{
11
    private $parameters = [];
12
13 3
    public function addParameters(Objects\ParameterFactory ...$parameters): self
14
    {
15 3
        foreach ($parameters as $parameter) {
16 3
            $this->parameters[] = $parameter;
17
        }
18
19 3
        return $this;
20
    }
21
22 3
    public function createParameterCollection(): Objects\ParameterCollection
23
    {
24 3
        return new Objects\ParameterCollection(
25 3
            array_map(
26
                static function (Objects\ParameterFactory $factory): Objects\Parameter {
27 3
                    return $factory->createParameter();
28 3
                },
29 3
                $this->getParameters()
30
            )
31
        );
32
    }
33
34 3
    private function getParameters(): array
35
    {
36 3
        return $this->parameters;
37
    }
38
}
39