Conditions | 14 |
Paths | 516 |
Total Lines | 62 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
12 | public function collect(Atomizer $atomizer): array |
||
13 | { |
||
14 | $result = []; |
||
15 | |||
16 | foreach ($atomizer->getTables() as $table) { |
||
17 | if ($table->getStatus() === AbstractTable::STATUS_NEW) { |
||
18 | $result[] = [ChangeType::CreateTable, $table->getName()]; |
||
19 | continue; |
||
20 | } |
||
21 | |||
22 | if ($table->getStatus() === AbstractTable::STATUS_DECLARED_DROPPED) { |
||
23 | $result[] = [ChangeType::DropTable, $table->getName()]; |
||
24 | continue; |
||
25 | } |
||
26 | |||
27 | if ($table->getComparator()->isRenamed()) { |
||
28 | $result[] = [ChangeType::RenameTable, $table->getInitialName()]; |
||
29 | continue; |
||
30 | } |
||
31 | |||
32 | $result[] = [ChangeType::ChangeTable, $table->getName()]; |
||
33 | |||
34 | $comparator = $table->getComparator(); |
||
35 | |||
36 | foreach ($comparator->addedColumns() as $column) { |
||
37 | $result[] = [ChangeType::AddColumn, $column->getName()]; |
||
38 | } |
||
39 | |||
40 | foreach ($comparator->droppedColumns() as $column) { |
||
41 | $result[] = [ChangeType::DropColumn, $column->getName()]; |
||
42 | } |
||
43 | |||
44 | foreach ($comparator->alteredColumns() as $column) { |
||
45 | $result[] = [ChangeType::AlterColumn, $column[0]->getName()]; |
||
46 | } |
||
47 | |||
48 | foreach ($comparator->addedIndexes() as $index) { |
||
49 | $result[] = [ChangeType::AddIndex, $index->getName()]; |
||
50 | } |
||
51 | |||
52 | foreach ($comparator->droppedIndexes() as $index) { |
||
53 | $result[] = [ChangeType::DropIndex, $index->getName()]; |
||
54 | } |
||
55 | |||
56 | foreach ($comparator->alteredIndexes() as $index) { |
||
57 | $result[] = [ChangeType::AlterIndex, $index[0]->getName()]; |
||
58 | } |
||
59 | |||
60 | foreach ($comparator->addedForeignKeys() as $fk) { |
||
61 | $result[] = [ChangeType::AddFk, $fk->getName()]; |
||
62 | } |
||
63 | |||
64 | foreach ($comparator->droppedForeignKeys() as $fk) { |
||
65 | $result[] = [ChangeType::DropFk, $fk->getName()]; |
||
66 | } |
||
67 | |||
68 | foreach ($comparator->alteredForeignKeys() as $fk) { |
||
69 | $result[] = [ChangeType::AlterFk, $fk[0]->getName()]; |
||
70 | } |
||
71 | } |
||
72 | |||
73 | return $result; |
||
74 | } |
||
76 |