MorphedHasOne   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 35
ccs 3
cts 3
cp 1
rs 10
c 3
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 16 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation\Relation\Morphed;
6
7
use Cycle\Annotated\Annotation\Relation\Inverse;
8
use Cycle\Annotated\Annotation\Relation\Relation;
9
use Cycle\Annotated\Annotation\Relation\Traits\InverseTrait;
10
use JetBrains\PhpStorm\ExpectedValues;
11
use Spiral\Attributes\NamedArgumentConstructor;
12
13
/**
14
 * @Annotation
15
 * @NamedArgumentConstructor
16
 * @Target("PROPERTY")
17
 */
18
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
19
final class MorphedHasOne extends Relation
20
{
21
    use InverseTrait;
22
23
    protected const TYPE = 'morphedHasOne';
24
25
    /**
26
     * @param non-empty-string $target
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
27
     * @param bool $cascade Automatically save related data with parent entity.
28
     * @param bool $nullable Defines if the relation can be nullable (child can have no parent).
29
     * @param array|string|null $innerKey Inner key in parent entity. Defaults to the primary key.
30
     * @param array|string|null $outerKey Outer key name. Defaults to `{parentRole}_{innerKey}`.
31
     * @param string $morphKey Name of key to store related entity role. Defaults to `{relationName}_role`.
32
     * @param int $morphKeyLength The length of morph key.
33
     * @param bool $indexCreate Create an index on morphKey and innerKey.
34
     * @param non-empty-string $load Relation load approach.
35
     * @param Inverse|null $inverse
36
     */
37 496
    public function __construct(
38
        string $target,
39
        protected bool $cascade = true,
40
        protected bool $nullable = false,
41
        protected array|string|null $innerKey = null,
42
        protected array|string|null $outerKey = null,
43
        protected ?string $morphKey = null,
44
        protected int $morphKeyLength = 32,
45
        protected bool $indexCreate = true,
46
        #[ExpectedValues(values: ['lazy', 'eager'])]
47
        string $load = 'lazy',
48
        ?Inverse $inverse = null,
49
    ) {
50 496
        $this->inverse = $inverse;
51
52 496
        parent::__construct($target, $load);
53 496
    }
54
}
55