Passed
Pull Request — master (#17)
by Aleksei
03:11
created

HasMany::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
c 0
b 0
f 0
dl 0
loc 15
rs 10
cc 1
nc 1
nop 11

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 Cycle\Annotated\Annotation\Relation;
6
7
use JetBrains\PhpStorm\ExpectedValues;
8
9
final class HasMany
10
{
11
    public function __construct(
12
        string $target,
13
        bool $cascade = true,
14
        bool $nullable = false,
15
        string $innerKey = null,
16
        string $outerKey = '{parentRole}_{innerKey}',
17
        array $where = [],
18
        array $orderBy = [],
19
        bool $fkCreate = true,
20
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
21
        string $fkAction = 'CASCADE',
22
        bool $indexCreate = true,
23
        #[ExpectedValues(values: ['lazy', 'eager'])]
24
        string $load = 'lazy'
25
    ) {
26
    }
27
}
28