| Conditions | 4 |
| Paths | 8 |
| Total Lines | 58 |
| Code Lines | 52 |
| 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 |
||
| 36 | public function createPlatform($unsafe = false) |
||
| 37 | { |
||
| 38 | $platform = $this->createMock('Doctrine\Tests\DBAL\Mocks\MockPlatform'); |
||
| 39 | $platform->expects($this->exactly(1)) |
||
| 40 | ->method('getCreateSchemaSQL') |
||
| 41 | ->with('foo_ns') |
||
|
|
|||
| 42 | ->will($this->returnValue('create_schema')); |
||
| 43 | if ($unsafe) { |
||
| 44 | $platform->expects($this->exactly(1)) |
||
| 45 | ->method('getDropSequenceSql') |
||
| 46 | ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) |
||
| 47 | ->will($this->returnValue('drop_seq')); |
||
| 48 | } |
||
| 49 | $platform->expects($this->exactly(1)) |
||
| 50 | ->method('getAlterSequenceSql') |
||
| 51 | ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) |
||
| 52 | ->will($this->returnValue('alter_seq')); |
||
| 53 | $platform->expects($this->exactly(1)) |
||
| 54 | ->method('getCreateSequenceSql') |
||
| 55 | ->with($this->isInstanceOf('Doctrine\DBAL\Schema\Sequence')) |
||
| 56 | ->will($this->returnValue('create_seq')); |
||
| 57 | if ($unsafe) { |
||
| 58 | $platform->expects($this->exactly(1)) |
||
| 59 | ->method('getDropTableSql') |
||
| 60 | ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) |
||
| 61 | ->will($this->returnValue('drop_table')); |
||
| 62 | } |
||
| 63 | $platform->expects($this->exactly(1)) |
||
| 64 | ->method('getCreateTableSql') |
||
| 65 | ->with($this->isInstanceof('Doctrine\DBAL\Schema\Table')) |
||
| 66 | ->will($this->returnValue(array('create_table'))); |
||
| 67 | $platform->expects($this->exactly(1)) |
||
| 68 | ->method('getCreateForeignKeySQL') |
||
| 69 | ->with($this->isInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint')) |
||
| 70 | ->will($this->returnValue('create_foreign_key')); |
||
| 71 | $platform->expects($this->exactly(1)) |
||
| 72 | ->method('getAlterTableSql') |
||
| 73 | ->with($this->isInstanceOf('Doctrine\DBAL\Schema\TableDiff')) |
||
| 74 | ->will($this->returnValue(array('alter_table'))); |
||
| 75 | if ($unsafe) { |
||
| 76 | $platform->expects($this->exactly(1)) |
||
| 77 | ->method('getDropForeignKeySql') |
||
| 78 | ->with( |
||
| 79 | $this->isInstanceof('Doctrine\DBAL\Schema\ForeignKeyConstraint'), |
||
| 80 | $this->isInstanceOf('Doctrine\DBAL\Schema\Table') |
||
| 81 | ) |
||
| 82 | ->will($this->returnValue('drop_orphan_fk')); |
||
| 83 | } |
||
| 84 | $platform->expects($this->exactly(1)) |
||
| 85 | ->method('supportsSchemas') |
||
| 86 | ->will($this->returnValue(true)); |
||
| 87 | $platform->expects($this->exactly(1)) |
||
| 88 | ->method('supportsSequences') |
||
| 89 | ->will($this->returnValue(true)); |
||
| 90 | $platform->expects($this->exactly(2)) |
||
| 91 | ->method('supportsForeignKeyConstraints') |
||
| 92 | ->will($this->returnValue(true)); |
||
| 93 | return $platform; |
||
| 94 | } |
||
| 115 |