Passed
Push — 3.x ( 42ab4a...bb376d )
by Aleksei
12:31 queued 16s
created

ForeignKey::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 5
dl 0
loc 11
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation;
6
7
use Doctrine\Common\Annotations\Annotation\Target;
8
use JetBrains\PhpStorm\ExpectedValues;
9
use Spiral\Attributes\NamedArgumentConstructor;
10
11
/**
12
 * @Annotation
13
 *
14
 * @NamedArgumentConstructor
15
 *
16
 * @Target({"PROPERTY", "ANNOTATION", "CLASS"})
17
 */
18
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)]
19
#[NamedArgumentConstructor]
20
class ForeignKey
21
{
22
    /**
23
     * @param non-empty-string $target Role or class name of the target entity.
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...
24
     * @param list<non-empty-string>|non-empty-string|null $innerKey You don't need to specify this if the attribute
25
     *        is used on a property.
26
     * @param list<non-empty-string>|non-empty-string|null $outerKey Outer key in the target entity.
27
     *        Defaults to the primary key.
28
     * @param 'CASCADE'|'NO ACTION'|'SET null' $action
29
     * @param bool $indexCreate Note: MySQL and MSSQL might create an index for the foreign key automatically.
30
     */
31
    public function __construct(
32
        public string $target,
33
        public array|string|null $innerKey = null,
34
        public array|string|null $outerKey = null,
35
        /**
36
         * @Enum({"NO ACTION", "CASCADE", "SET NULL"})
37
         */
38
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
39
        public string $action = 'CASCADE',
40
        public bool $indexCreate = true,
41
    ) {
42
    }
43
}
44