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