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
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 | } |