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

Index::getColumns()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
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\Table;
11
12
use Cycle\Annotated\Annotation\Column;
13
use Doctrine\Common\Annotations\Annotation\Attribute;
14
use Doctrine\Common\Annotations\Annotation\Attributes;
15
use Doctrine\Common\Annotations\Annotation\Target;
16
17
/**
18
 * @Annotation
19
 * @Target("ANNOTATION")
20
 * @Attributes({
21
 *      @Attribute("columns", type="array<string>", required=true),
22
 *      @Attribute("unique", type="bool"),
23
 *      @Attribute("name", type="string"),
24
 * })
25
 */
26
class Index
27
{
28
    /** @var array<string> */
29
    private $columns = [];
30
31
    /** @var bool */
32
    private $unique = false;
33
34
    /** @var string */
35
    private $name;
36
37
    /**
38
     * @param array $values
39
     */
40
    public function __construct(array $values)
41
    {
42
        foreach ($values as $key => $value) {
43
            $this->$key = $value;
44
        }
45
    }
46
47
    /**
48
     * @return Column[]
49
     */
50
    public function getColumns(): array
51
    {
52
        return $this->columns;
0 ignored issues
show
Bug Best Practice introduced by Wolfy-J
The expression return $this->columns returns the type string[] which is incompatible with the documented return type Cycle\Annotated\Annotation\Column[].
Loading history...
53
    }
54
55
56
    /**
57
     * @return string|null
58
     */
59
    public function getIndex(): ?string
60
    {
61
        return $this->name;
62
    }
63
64
    /**
65
     * @return bool
66
     */
67
    public function isUnique(): bool
68
    {
69
        return $this->unique;
70
    }
71
}