| Conditions | 5 |
| Paths | 60 |
| Total Lines | 58 |
| Code Lines | 41 |
| 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 |
||
| 63 | protected function setUp() : void |
||
| 64 | { |
||
| 65 | if (! extension_loaded('mysqli')) { |
||
| 66 | $this->markTestSkipped('mysqli is not installed.'); |
||
| 67 | } |
||
| 68 | |||
| 69 | parent::setUp(); |
||
| 70 | |||
| 71 | if (! ($this->connection->getDriver() instanceof Driver)) { |
||
| 72 | $this->markTestSkipped('MySQLi only test.'); |
||
| 73 | } |
||
| 74 | |||
| 75 | if ($this->connection->getSchemaManager()->tablesExist('mysqli_statement_test')) { |
||
| 76 | return; |
||
| 77 | } |
||
| 78 | |||
| 79 | try { |
||
| 80 | $table = new Table('mysqli_statement_test'); |
||
| 81 | $table->addColumn('id', 'integer'); |
||
| 82 | $table->addColumn('foo', 'string'); |
||
| 83 | $table->addColumn('bar', 'string'); |
||
| 84 | $table->setPrimaryKey(['id']); |
||
| 85 | |||
| 86 | $sm = $this->connection->getSchemaManager(); |
||
| 87 | $sm->createTable($table); |
||
| 88 | |||
| 89 | $this->connection->insert('mysqli_statement_test', [ |
||
| 90 | 'id' => 1, |
||
| 91 | 'foo' => 1, |
||
| 92 | 'bar' => 1, |
||
| 93 | ]); |
||
| 94 | $this->connection->insert('mysqli_statement_test', [ |
||
| 95 | 'id' => 2, |
||
| 96 | 'foo' => 1, |
||
| 97 | 'bar' => 2, |
||
| 98 | ]); |
||
| 99 | $this->connection->insert('mysqli_statement_test', [ |
||
| 100 | 'id' => 3, |
||
| 101 | 'foo' => 1, |
||
| 102 | 'bar' => 3, |
||
| 103 | ]); |
||
| 104 | $this->connection->insert('mysqli_statement_test', [ |
||
| 105 | 'id' => 4, |
||
| 106 | 'foo' => 1, |
||
| 107 | 'bar' => 4, |
||
| 108 | ]); |
||
| 109 | $this->connection->insert('mysqli_statement_test', [ |
||
| 110 | 'id' => 5, |
||
| 111 | 'foo' => 2, |
||
| 112 | 'bar' => 1, |
||
| 113 | ]); |
||
| 114 | $this->connection->insert('mysqli_statement_test', [ |
||
| 115 | 'id' => 6, |
||
| 116 | 'foo' => 2, |
||
| 117 | 'bar' => 2, |
||
| 118 | ]); |
||
| 119 | } catch (Throwable $e) { |
||
| 120 | $this->fail($e->getMessage()); |
||
| 121 | } |
||
| 143 |