| Conditions | 4 |
| Paths | 5 |
| Total Lines | 77 |
| Code Lines | 57 |
| 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 |
||
| 23 | public function testColumnSchema(): void |
||
| 24 | { |
||
| 25 | $columns = $this->getExpectedColumns(); |
||
|
|
|||
| 26 | |||
| 27 | $db = $this->getConnection(); |
||
| 28 | |||
| 29 | $schema = $db->getSchema(); |
||
| 30 | $table = $schema->getTableSchema('type', true); |
||
| 31 | |||
| 32 | $this->assertNotNull($table); |
||
| 33 | |||
| 34 | $expectedColNames = array_keys($columns); |
||
| 35 | sort($expectedColNames); |
||
| 36 | $colNames = $table->getColumnNames(); |
||
| 37 | sort($colNames); |
||
| 38 | |||
| 39 | $this->assertSame($expectedColNames, $colNames); |
||
| 40 | |||
| 41 | foreach ($table->getColumns() as $name => $column) { |
||
| 42 | $expected = $columns[$name]; |
||
| 43 | $this->assertSame( |
||
| 44 | $expected['dbType'], |
||
| 45 | $column->getDbType(), |
||
| 46 | "dbType of column $name does not match. type is {$column->getType()}, dbType is {$column->getDbType()}." |
||
| 47 | ); |
||
| 48 | $this->assertSame( |
||
| 49 | $expected['phpType'], |
||
| 50 | $column->getPhpType(), |
||
| 51 | "phpType of column $name does not match. type is {$column->getType()}, dbType is {$column->getDbType()}." |
||
| 52 | ); |
||
| 53 | $this->assertSame($expected['type'], $column->getType(), "type of column $name does not match."); |
||
| 54 | $this->assertSame( |
||
| 55 | $expected['allowNull'], |
||
| 56 | $column->isAllowNull(), |
||
| 57 | "allowNull of column $name does not match." |
||
| 58 | ); |
||
| 59 | $this->assertSame( |
||
| 60 | $expected['autoIncrement'], |
||
| 61 | $column->isAutoIncrement(), |
||
| 62 | "autoIncrement of column $name does not match." |
||
| 63 | ); |
||
| 64 | $this->assertSame( |
||
| 65 | $expected['enumValues'], |
||
| 66 | $column->getEnumValues(), |
||
| 67 | "enumValues of column $name does not match." |
||
| 68 | ); |
||
| 69 | $this->assertSame($expected['size'], $column->getSize(), "size of column $name does not match."); |
||
| 70 | $this->assertSame( |
||
| 71 | $expected['precision'], |
||
| 72 | $column->getPrecision(), |
||
| 73 | "precision of column $name does not match." |
||
| 74 | ); |
||
| 75 | $this->assertSame($expected['scale'], $column->getScale(), "scale of column $name does not match."); |
||
| 76 | if (is_object($expected['defaultValue'])) { |
||
| 77 | $this->assertIsObject( |
||
| 78 | $column->getDefaultValue(), |
||
| 79 | "defaultValue of column $name is expected to be an object but it is not." |
||
| 80 | ); |
||
| 81 | $this->assertEquals( |
||
| 82 | (string) $expected['defaultValue'], |
||
| 83 | (string) $column->getDefaultValue(), |
||
| 84 | "defaultValue of column $name does not match." |
||
| 85 | ); |
||
| 86 | } else { |
||
| 87 | $this->assertEquals( |
||
| 88 | $expected['defaultValue'], |
||
| 89 | $column->getDefaultValue(), |
||
| 90 | "defaultValue of column $name does not match." |
||
| 91 | ); |
||
| 92 | } |
||
| 93 | /* Pgsql only */ |
||
| 94 | if (isset($expected['dimension'])) { |
||
| 95 | /** @psalm-suppress UndefinedMethod */ |
||
| 96 | $this->assertSame( |
||
| 97 | $expected['dimension'], |
||
| 98 | $column->getDimension(), |
||
| 99 | "dimension of column $name does not match" |
||
| 100 | ); |
||
| 105 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.