Total Complexity | 7 |
Total Lines | 63 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
4 | abstract class BasicKey extends DatabaseItem implements Commitable |
||
5 | { |
||
6 | protected $columns; |
||
7 | protected $table; |
||
8 | protected $name; |
||
9 | |||
10 | public function __construct($columns, $table) |
||
11 | { |
||
12 | $this->columns = $columns; |
||
13 | $this->table = $table; |
||
14 | } |
||
15 | |||
16 | #[\Override] |
||
32 | } |
||
33 | } |
||
34 | |||
35 | abstract protected function doesKeyExist($constraint); |
||
36 | abstract protected function addKey($constraint); |
||
37 | abstract protected function dropKey($constraint); |
||
38 | abstract protected function getNamePostfix(); |
||
39 | |||
40 | #[\Override] |
||
41 | protected function buildDescription() |
||
42 | { |
||
43 | return array( |
||
44 | 'table' => $this->table->getName(), |
||
45 | 'schema' => $this->table->getSchema()->getName(), |
||
46 | 'columns' => $this->columns, |
||
47 | 'name' => $this->name |
||
48 | ); |
||
49 | } |
||
50 | |||
51 | #[\Override] |
||
52 | public function commitNew() |
||
53 | { |
||
54 | $this->addKey($this->buildDescription()); |
||
55 | } |
||
56 | |||
57 | public function drop() |
||
58 | { |
||
59 | $this->dropKey($this->getKeyDescription()); |
||
|
|||
60 | return $this; |
||
61 | } |
||
62 | |||
63 | public function name($name) |
||
67 | } |
||
68 | } |
||
69 | |||
70 |