Issues (6)

src/Annotation/Table/Index.php (1 issue)

1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Cycle\Annotated\Annotation\Table;
13
14
use Cycle\Annotated\Annotation\Column;
15
use Doctrine\Common\Annotations\Annotation\Attribute;
16
use Doctrine\Common\Annotations\Annotation\Attributes;
17
use Doctrine\Common\Annotations\Annotation\Target;
18
19
/**
20
 * @Annotation
21
 * @Target("ANNOTATION")
22
 * @Attributes({
23
 *      @Attribute("columns", type="array<string>", required=true),
24
 *      @Attribute("unique", type="bool"),
25
 *      @Attribute("name", type="string"),
26
 * })
27
 */
28
class Index
29
{
30
    /** @var array<string> */
31
    private $columns = [];
32
33
    /** @var bool */
34
    private $unique = false;
35
36
    /** @var string */
37
    private $name;
38
39
    /**
40
     * @param array $values
41
     */
42
    public function __construct(array $values)
43
    {
44
        foreach ($values as $key => $value) {
45
            $this->$key = $value;
46
        }
47
    }
48
49
    /**
50
     * @return Column[]
51
     */
52
    public function getColumns(): array
53
    {
54
        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...
55
    }
56
57
58
    /**
59
     * @return string|null
60
     */
61
    public function getIndex(): ?string
62
    {
63
        return $this->name;
64
    }
65
66
    /**
67
     * @return bool
68
     */
69
    public function isUnique(): bool
70
    {
71
        return $this->unique;
72
    }
73
}
74