Passed
Pull Request — 3.x (#43)
by Aleksei
14:43
created

JoinedTable::getFkAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 0
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation\Inheritance;
6
7
use Cycle\Annotated\Annotation\Inheritance;
8
use Doctrine\Common\Annotations\Annotation\NamedArgumentConstructor;
9
use JetBrains\PhpStorm\ExpectedValues;
10
11
/**
12
 * @Annotation
13
 * @NamedArgumentConstructor
14
 * @Target("CLASS")
15
 */
16
#[\Attribute(\Attribute::TARGET_CLASS), NamedArgumentConstructor]
17
class JoinedTable extends Inheritance
18 72
{
19
    /**
20
     * @param non-empty-string|null $outerKey Outer (parent) key name.
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string|null at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string|null.
Loading history...
21 72
     * @param bool $fkCreate Set to true to automatically create FK on outerKey.
22 72
     * @param non-empty-string|null $fkAction FK onDelete and onUpdate action.
23
     */
24 72
    public function __construct(
25
        private ?string $outerKey = null,
26 72
        private bool $fkCreate = true,
27
        /**
28
         * @Enum({"NO ACTION", "CASCADE", "SET NULL"})
29
         */
30
        #[ExpectedValues(values: ['NO ACTION', 'CASCADE', 'SET NULL'])]
31
        private ?string $fkAction = 'CASCADE',
32
    ) {
33
        parent::__construct('joined');
34
    }
35
36
    public function getOuterKey(): ?string
37
    {
38
        return $this->outerKey;
39
    }
40
41
    public function isCreateFk(): bool
42
    {
43
        return $this->fkCreate;
44
    }
45
46
    public function getFkAction(): string
47
    {
48
        return $this->fkAction;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->fkAction could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
49
    }
50
}
51