Passed
Pull Request — master (#17)
by Aleksei
02:50
created

HasOne::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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

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 HasOne
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
        bool $fkCreate = true,
25
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
26
        string $fkAction = 'CASCADE',
27
        bool $indexCreate = true,
28
        #[ExpectedValues(values: ['lazy', 'eager'])]
29
        string $load = 'lazy',
30
        // Inverse $inverse = null, // can be uncommented for compatibility with php 8.1
31
    ) {
32
    }
33
}
34