Passed
Pull Request — master (#19)
by
unknown
03:08
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 array<Column> */
26
    private $columns = [];
27
28
    /** @var PrimaryKey */
29
    private $primary = null;
30
31
    /** @var array<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
    /**
53
     * @return ?PrimaryKey
54
     */
55
    public function getPrimary(): ?PrimaryKey
56
    {
57
        return $this->primary;
58
    }
59
60
    /**
61
     * @return Index[]
62
     */
63
    public function getIndexes(): array
64
    {
65
        return $this->indexes;
66
    }
67
}
68