Passed
Push — master ( c93c78...d9ab06 )
by Anton
04:33 queued 02:57
created

Relation::getType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Spiral Framework.
4
 *
5
 * @license   MIT
6
 * @author    Anton Titov (Wolfy-J)
7
 */
8
declare(strict_types=1);
9
10
namespace Cycle\Annotated\Annotation\Relation;
11
12
use Doctrine\Common\Annotations\Annotation\Enum;
13
use Doctrine\Common\Annotations\Annotation\Required;
14
15
abstract class Relation implements RelationInterface
16
{
17
    // relation type
18
    protected const TYPE = '';
19
20
    /**
21
     * @Required()
22
     * @var string
23
     */
24
    protected $target;
25
26
    /**
27
     * @Enum({"eager", "lazy", "promise"}
28
     * @var string
29
     */
30
    protected $load;
31
32
    /**
33
     * @param array $values
34
     */
35
    public function __construct(array $values)
36
    {
37
        foreach ($values as $key => $value) {
38
            if ($key == "fetch") {
39
                $key = "load";
40
            }
41
42
            $this->$key = $value;
43
        }
44
    }
45
46
    /**
47
     * @return string
48
     */
49
    public function getType(): string
50
    {
51
        return static::TYPE;
52
    }
53
54
    /**
55
     * @return string|null
56
     */
57
    public function getTarget(): ?string
58
    {
59
        return $this->target;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    public function getOptions(): array
66
    {
67
        $options = get_object_vars($this);
68
        unset($options['target'], $options['inverse']);
69
70
        return $options;
71
    }
72
}