Embedded   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
eloc 10
c 2
b 0
f 1
dl 0
loc 37
ccs 11
cts 11
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setPrefix() 0 5 1
A getPrefix() 0 3 1
A getInverse() 0 3 1
A __construct() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation\Relation;
6
7
use JetBrains\PhpStorm\ExpectedValues;
8
use Spiral\Attributes\NamedArgumentConstructor;
9
10
/**
11
 * @Annotation
12
 * @NamedArgumentConstructor
13
 * @Target("PROPERTY")
14
 */
15
#[\Attribute(\Attribute::TARGET_PROPERTY), NamedArgumentConstructor]
16
final class Embedded extends Relation
17
{
18
    protected const TYPE = 'embedded';
19
    protected ?string $embeddedPrefix = null;
20
21
    /**
22
     * @param non-empty-string $target Entity to embed.
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...
23
     * @param 'eager'|'lazy' $load Relation load approach.
24
     * @param string|null $prefix Prefix for embedded entity columns.
25
     */
26 72
    public function __construct(
27
        string $target,
28
        #[ExpectedValues(values: ['lazy', 'eager'])]
29
        string $load = 'eager',
30
        ?string $prefix = null,
31
    ) {
32 72
        $this->embeddedPrefix = $prefix;
33
34 72
        parent::__construct($target, $load);
35 72
    }
36
37 72
    public function getInverse(): ?Inverse
38
    {
39 72
        return null;
40
    }
41
42 72
    public function getPrefix(): ?string
43
    {
44 72
        return $this->embeddedPrefix;
45
    }
46
47 72
    public function setPrefix(string $prefix): self
48
    {
49 72
        $this->embeddedPrefix = $prefix;
50
51 72
        return $this;
52
    }
53
}
54