BelongsToMorphed   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 34
ccs 3
cts 3
cp 1
rs 10
c 1
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 Doctrine\Common\Annotations\Annotation\Target;
11
use JetBrains\PhpStorm\ExpectedValues;
12
use Spiral\Attributes\NamedArgumentConstructor;
13
14
/**
15
 * @Annotation
16
 * @NamedArgumentConstructor
17
 * @Target("PROPERTY")
18
 */
19
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
20
final class BelongsToMorphed extends Relation
21
{
22
    use InverseTrait;
23
24
    protected const TYPE = 'belongsToMorphed';
25
26
    /**
27
     * @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...
28
     * @param bool $cascade Automatically save related data with source entity.
29
     * @param bool $nullable Defines if the relation can be nullable (child can have no parent).
30
     * @param array|string|null $innerKey Inner key in source entity. Defaults to `{relationName}_{outerKey}`.
31
     * @param array|string|null $outerKey Outer key in the related entity. Defaults to primary key.
32
     * @param string $morphKey Name of key to store related entity role. Defaults to `{relationName}_role`.
33
     * @param int $morphKeyLength The length of morph key.
34
     * @param bool $indexCreate Create an index on morphKey and innerKey.
35
     * @param non-empty-string $load Relation load approach.
36
     */
37 592
    public function __construct(
38
        string $target,
39
        protected bool $cascade = true,
40
        protected bool $nullable = true,
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 592
        $this->inverse = $inverse;
51
52 592
        parent::__construct($target, $load);
53 592
    }
54
}
55