Passed
Pull Request — master (#19)
by Aleksei
02:13
created

Table::getPrimary()   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
declare(strict_types=1);
4
5
namespace Cycle\Annotated\Annotation;
6
7
use Cycle\Annotated\Annotation\Table\Index;
8
use Cycle\Annotated\Annotation\Table\PrimaryKey;
9
use Doctrine\Common\Annotations\Annotation\Attribute;
10
use Doctrine\Common\Annotations\Annotation\Attributes;
11
use Doctrine\Common\Annotations\Annotation\Target;
12
13
/**
14
 * @Annotation
15
 * @Target({"CLASS", "ANNOTATION"})
16
 * @Attributes({
17
 *      @Attribute("columns", type="array<Cycle\Annotated\Annotation\Column>"),
18
 *      @Attribute("primary", type="Cycle\Annotated\Annotation\Table\PrimaryKey"),
19
 *      @Attribute("indexes", type="array<Cycle\Annotated\Annotation\Table\Index>"),
20
 * })
21
 */
22
#[\Attribute(\Attribute::TARGET_CLASS)]
23
final class Table
24
{
25
    /** @var Column[] */
26
    private $columns = [];
27
28
    /** @var PrimaryKey|null */
29
    private $primary = null;
30
31
    /** @var Index[] */
32
    private $indexes = [];
33
34
    /**
35
     * @param array $values
36
     */
37
    public function __construct(array $values)
38
    {
39
        foreach ($values as $key => $value) {
40
            $this->$key = $value;
41
        }
42
    }
43
44
    /**
45
     * @return Column[]
46
     */
47
    public function getColumns(): array
48
    {
49
        return $this->columns;
50
    }
51
52
    public function getPrimary(): ?PrimaryKey
53
    {
54
        return $this->primary;
55
    }
56
57
    /**
58
     * @return Index[]
59
     */
60
    public function getIndexes(): array
61
    {
62
        return $this->indexes;
63
    }
64
}
65