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

HasMany::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 0
c 0
b 0
f 0
dl 0
loc 16
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
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Annotated\Annotation\Relation;
13
14
use JetBrains\PhpStorm\ExpectedValues;
15
16
final class HasMany
17
{
18
    public function __construct(
19
        string $target,
20
        bool $cascade = true,
21
        bool $nullable = false,
22
        string $innerKey = null,
23
        string $outerKey = '{parentRole}_{innerKey}',
24
        array $where = [],
25
        array $orderBy = [],
26
        bool $fkCreate = true,
27
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
28
        string $fkAction = 'CASCADE',
29
        bool $indexCreate = true,
30
        #[ExpectedValues(values: ['lazy', 'eager'])]
31
        string $load = 'lazy',
32
        // Inverse $inverse = null, // can be uncommented for compatibility with php 8.1
33
    ) {
34
    }
35
}
36