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

MorphedHasOne::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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

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\Morphed;
6
7
use JetBrains\PhpStorm\ExpectedValues;
8
9
final class MorphedHasOne
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
        string $morphKey = '{relationName}_role',
18
        int $morphKeyLength = 32,
19
        bool $indexCreate = true,
20
        #[ExpectedValues(values: ['lazy', 'eager'])]
21
        string $load = 'lazy',
22
        // Inverse $inverse = null, // can be uncommented for compatibility with php 8.1
23
    ) {
24
    }
25
}
26