1 | <?php |
||
8 | class Index implements Buildable |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $separator = '_'; |
||
14 | |||
15 | /** |
||
16 | * Suffix to be added to the index key name |
||
17 | * |
||
18 | * @var string |
||
19 | */ |
||
20 | protected $suffix = 'index'; |
||
21 | |||
22 | /** |
||
23 | * @var ClassMetadataBuilder |
||
24 | */ |
||
25 | protected $builder; |
||
26 | |||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | protected $columns; |
||
31 | |||
32 | /** |
||
33 | * @var string|null |
||
34 | */ |
||
35 | protected $name = null; |
||
36 | |||
37 | /** |
||
38 | * @param ClassMetadataBuilder $builder |
||
39 | * @param string[] $columns |
||
40 | */ |
||
41 | 12 | public function __construct(ClassMetadataBuilder $builder, array $columns) |
|
42 | { |
||
43 | 12 | $this->builder = $builder; |
|
44 | 12 | $this->columns = $columns; |
|
45 | 12 | } |
|
46 | |||
47 | /** |
||
48 | * Execute the build process |
||
49 | */ |
||
50 | 3 | public function build() |
|
51 | { |
||
52 | 3 | $this->builder->addIndex( |
|
53 | 3 | $this->getColumns(), |
|
54 | 3 | $this->getName() |
|
55 | 3 | ); |
|
56 | 3 | } |
|
57 | |||
58 | /** |
||
59 | * @param string $name |
||
60 | * |
||
61 | * @return $this |
||
62 | */ |
||
63 | 2 | public function name($name) |
|
64 | { |
||
65 | 2 | $this->name = $name; |
|
66 | |||
67 | 2 | return $this; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return string[] |
||
72 | */ |
||
73 | 12 | public function getColumns() |
|
77 | |||
78 | /** |
||
79 | * @return string |
||
80 | */ |
||
81 | 6 | public function getName() |
|
85 | |||
86 | /** |
||
87 | * @return string |
||
88 | */ |
||
89 | 4 | protected function generateIndexName() |
|
95 | } |
||
96 |