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