ManyToMany   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 40 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation\Relation;
6
7
use Cycle\Annotated\Annotation\Relation\Traits\InverseTrait;
8
use Doctrine\Common\Annotations\Annotation\Enum;
9
use JetBrains\PhpStorm\ExpectedValues;
10
use Spiral\Attributes\NamedArgumentConstructor;
11
12
/**
13
 * @Annotation
14
 * @NamedArgumentConstructor
15
 * @Target("PROPERTY")
16
 */
17
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
18
final class ManyToMany extends Relation
19
{
20
    use InverseTrait;
21
22
    protected const TYPE = 'manyToMany';
23
24
    /**
25
     * @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...
26
     * @param array|non-empty-string|null $innerKey Inner key name in source entity. Defaults to a primary key.
27
     * @param array|non-empty-string|null $outerKey Outer key name in target entity. Defaults to a primary key.
28
     * @param array|non-empty-string|null $throughInnerKey Key name connected to the innerKey of source entity.
29
     *        Defaults to `{sourceRole}_{innerKey}`.
30
     * @param array|non-empty-string|null $throughOuterKey Key name connected to the outerKey of a related entity.
31
     *        Defaults to `{targetRole}_{outerKey}`.
32
     * @param bool $cascade Automatically save related data with parent entity.
33
     * @param bool $nullable Defines if the relation can be nullable (child can have no parent).
34
     * @param array $where Where conditions applied to a related entity.
35
     * @param array $orderBy Additional sorting rules.
36
     * @param class-string|non-empty-string|null $through Pivot entity.
37
     * @param array $throughWhere Where conditions applied to `through` entity.
38
     * @param bool $fkCreate Set to true to automatically create FK on thoughInnerKey and thoughOuterKey.
39
     * @param non-empty-string|null $fkAction FK onDelete and onUpdate action.
40
     * @param non-empty-string|null $fkOnDelete FK onDelete action. It has higher priority than {@see $fkAction}.
41
     *        Defaults to {@see $fkAction}.
42
     * @param bool $indexCreate Create index on [thoughInnerKey, thoughOuterKey].
43
     * @param non-empty-string|null $collection Collection that will contain loaded entities.
44
     * @param non-empty-string $load Relation load approach.
45
     */
46 568
    public function __construct(
47
        string $target,
48
        protected array|string|null $innerKey = null,
49
        protected array|string|null $outerKey = null,
50
        protected array|string|null $throughInnerKey = null,
51
        protected array|string|null $throughOuterKey = null,
52
        protected bool $cascade = true,
53
        protected bool $nullable = false,
54
        protected array $where = [],
55
        protected array $orderBy = [],
56
        protected ?string $through = null,
57
        protected array $throughWhere = [],
58
        protected bool $fkCreate = true,
59
        /**
60
         * @Enum({"NO ACTION", "CASCADE", "SET NULL"})
61
         */
62
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
63
        protected ?string $fkAction = 'CASCADE',
64
        /**
65
         * @Enum({"NO ACTION", "CASCADE", "SET NULL"})
66
         */
67
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
68
        protected ?string $fkOnDelete = null,
69
        protected bool $indexCreate = true,
70
        protected ?string $collection = null,
71
        #[ExpectedValues(values: ['lazy', 'eager'])]
72
        string $load = 'lazy',
73
        ?Inverse $inverse = null,
74
        /** @deprecated */
75
        protected ?string $though = null,
76
        /** @deprecated */
77
        protected array|string|null $thoughInnerKey = null,
78
        /** @deprecated */
79
        protected array|string|null $thoughOuterKey = null,
80
        /** @deprecated */
81
        protected array|null $thoughWhere = [],
82
    ) {
83 568
        $this->inverse = $inverse;
84
85 568
        parent::__construct($target, $load);
86 568
    }
87
}
88