| Conditions | 5 |
| Paths | 8 |
| Total Lines | 63 |
| Code Lines | 53 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 44 | private function createPlatform(bool $unsafe) |
||
| 45 | { |
||
| 46 | $platform = $this->createMock(AbstractPlatform::class); |
||
| 47 | assert($platform instanceof AbstractPlatform || $platform instanceof MockObject); |
||
| 48 | $platform->expects($this->exactly(1)) |
||
| 49 | ->method('getCreateSchemaSQL') |
||
| 50 | ->with('foo_ns') |
||
| 51 | ->will($this->returnValue('create_schema')); |
||
| 52 | if ($unsafe) { |
||
| 53 | $platform->expects($this->exactly(1)) |
||
| 54 | ->method('getDropSequenceSql') |
||
| 55 | ->with($this->isInstanceOf(Sequence::class)) |
||
| 56 | ->will($this->returnValue('drop_seq')); |
||
| 57 | } |
||
| 58 | |||
| 59 | $platform->expects($this->exactly(1)) |
||
| 60 | ->method('getAlterSequenceSql') |
||
| 61 | ->with($this->isInstanceOf(Sequence::class)) |
||
| 62 | ->will($this->returnValue('alter_seq')); |
||
| 63 | $platform->expects($this->exactly(1)) |
||
| 64 | ->method('getCreateSequenceSql') |
||
| 65 | ->with($this->isInstanceOf(Sequence::class)) |
||
| 66 | ->will($this->returnValue('create_seq')); |
||
| 67 | if ($unsafe) { |
||
| 68 | $platform->expects($this->exactly(1)) |
||
| 69 | ->method('getDropTableSql') |
||
| 70 | ->with($this->isInstanceOf(Table::class)) |
||
| 71 | ->will($this->returnValue('drop_table')); |
||
| 72 | } |
||
| 73 | |||
| 74 | $platform->expects($this->exactly(1)) |
||
| 75 | ->method('getCreateTableSql') |
||
| 76 | ->with($this->isInstanceOf(Table::class)) |
||
| 77 | ->will($this->returnValue(['create_table'])); |
||
| 78 | $platform->expects($this->exactly(1)) |
||
| 79 | ->method('getCreateForeignKeySQL') |
||
| 80 | ->with($this->isInstanceOf(ForeignKeyConstraint::class)) |
||
| 81 | ->will($this->returnValue('create_foreign_key')); |
||
| 82 | $platform->expects($this->exactly(1)) |
||
| 83 | ->method('getAlterTableSql') |
||
| 84 | ->with($this->isInstanceOf(TableDiff::class)) |
||
| 85 | ->will($this->returnValue(['alter_table'])); |
||
| 86 | if ($unsafe) { |
||
| 87 | $platform->expects($this->exactly(1)) |
||
| 88 | ->method('getDropForeignKeySql') |
||
| 89 | ->with( |
||
| 90 | $this->isInstanceOf(ForeignKeyConstraint::class), |
||
| 91 | $this->isInstanceOf(Table::class) |
||
| 92 | ) |
||
| 93 | ->will($this->returnValue('drop_orphan_fk')); |
||
| 94 | } |
||
| 95 | |||
| 96 | $platform->expects($this->exactly(1)) |
||
| 97 | ->method('supportsSchemas') |
||
| 98 | ->will($this->returnValue(true)); |
||
| 99 | $platform->expects($this->exactly(1)) |
||
| 100 | ->method('supportsSequences') |
||
| 101 | ->will($this->returnValue(true)); |
||
| 102 | $platform->expects($this->exactly(2)) |
||
| 103 | ->method('supportsForeignKeyConstraints') |
||
| 104 | ->will($this->returnValue(true)); |
||
| 105 | |||
| 106 | return $platform; |
||
| 107 | } |
||
| 129 |