Completed
Push — master ( 935a4f...80b369 )
by Veaceslav
01:53
created

Header::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 30

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 30
ccs 4
cts 4
cp 1
rs 9.44
c 0
b 0
f 0
cc 1
nc 1
nop 11
crap 1

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Objects;
6
7
use Aweapi\Openapi\Extensions;
8
9
final class Header extends Parameter implements HeaderAggregate
10
{
11 6
    public function __construct(
12
        SchemaAggregate $schema = null,
13
        MediaTypes $content = null,
14
        string $description = null,
15
        bool $required = null,
16
        bool $deprecated = false,
17
        bool $allowEmptyValue = false,
18
        string $style = null,
19
        bool $explode = null,
20
        bool $allowReserved = false,
21
        Examples $examples = null,
22
        Extensions $extensions = null
23
    ) {
24 6
        parent::__construct(
25
            // The name MUST not be used.
26 6
            '',
27 6
            'header',
28
            $schema,
29
            $content,
30
            $description,
31
            $required,
32
            $deprecated,
33
            $allowEmptyValue,
34
            $style,
35
            $explode,
36
            $allowReserved,
37
            $examples,
38
            $extensions
39
        );
40
    }
41
42 5
    protected function normalizeRequiredProperties(): array
43
    {
44 5
        $fields = parent::normalizeRequiredProperties();
45
        unset(
46
            // The field `name` MUST NOT be specified, it is given in the corresponding headers map.
47 5
            $fields['name'],
48
            // The field `in` MUST NOT be specified, it is implicitly in `header`.
49 5
            $fields['in']
50
        );
51
52 5
        return $fields;
53
    }
54
}
55