| Conditions | 1 | 
| Paths | 1 | 
| Total Lines | 52 | 
| Code Lines | 43 | 
| 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  | 
            ||
| 148 | public function testSelectComplexWithUnionAndExcept()  | 
            ||
| 149 |     { | 
            ||
| 150 |         $columnQuery = $this->getSut('quix') | 
            ||
| 151 |             ->addColumns('b') | 
            ||
| 152 |             ->addWhere(new Expr('id = ?', [7])); | 
            ||
| 153 | |||
| 154 |         $columnExpr = new Expr('NOW()'); | 
            ||
| 155 | |||
| 156 |         $unionQuery = $this->getSut('baz') | 
            ||
| 157 |             ->addColumns('b', 'f'); | 
            ||
| 158 | |||
| 159 |         $exceptQuery = $this->getSut('sec') | 
            ||
| 160 |             ->addColumns('v', 'w'); | 
            ||
| 161 | |||
| 162 |         $sql = (string)$this->getSut('foo', 'bar') | 
            ||
| 163 |             ->addModifier('DISTINCT') | 
            ||
| 164 |             ->addColumns('COUNT(DISTINCT baz) AS baz_count', new Column($columnQuery, 'quix_b')) | 
            ||
| 165 | ->addColumns(new Column($columnExpr, 'now'))  | 
            ||
| 166 |             ->addColumn('bar.id', 'bar_id') | 
            ||
| 167 |             ->addInnerJoin('quix', 'foo.id = q.foo_id', 'q') | 
            ||
| 168 |             ->addWhere('foo.bar = "foo-bar"', new Expr('bar.foo = ?', ['bar-foo'])) | 
            ||
| 169 |             ->addGroupBy('q.foo_id', new Expr('q.bar.id')) | 
            ||
| 170 |             ->addHaving('baz_count > 0') | 
            ||
| 171 |             ->addOrderBy('baz_count', 'ASC') | 
            ||
| 172 | ->addLock(Select::LOCK_FOR_UPDATE, Select::LOCK_NOWAIT)  | 
            ||
| 173 |             ->addLockTable('foo') | 
            ||
| 174 | ->setLimit(10)  | 
            ||
| 175 | ->setOffset(20)  | 
            ||
| 176 | ->addUnion($unionQuery)  | 
            ||
| 177 | ->addExcept($exceptQuery);  | 
            ||
| 178 | |||
| 179 | $parts = [];  | 
            ||
| 180 | $parts[] = 'SELECT DISTINCT COUNT(DISTINCT baz) AS baz_count, (SELECT b FROM quix WHERE id = ?) AS quix_b, NOW() AS now, bar.id AS bar_id'; // nolint  | 
            ||
| 181 | $parts[] = 'FROM foo, bar';  | 
            ||
| 182 | $parts[] = 'INNER JOIN quix AS q ON foo.id = q.foo_id';  | 
            ||
| 183 | $parts[] = 'WHERE foo.bar = "foo-bar" AND bar.foo = ?';  | 
            ||
| 184 | $parts[] = 'GROUP BY q.foo_id, q.bar.id';  | 
            ||
| 185 | $parts[] = 'HAVING baz_count > 0';  | 
            ||
| 186 | $parts[] = 'ORDER BY baz_count ASC';  | 
            ||
| 187 | $parts[] = 'OFFSET 20 ROWS';  | 
            ||
| 188 | $parts[] = 'FETCH FIRST 10 ROWS ONLY';  | 
            ||
| 189 | $parts[] = 'FOR UPDATE OF foo NOWAIT';  | 
            ||
| 190 | $parts[] = 'UNION';  | 
            ||
| 191 | $parts[] = 'SELECT b, f';  | 
            ||
| 192 | $parts[] = 'FROM baz';  | 
            ||
| 193 | $parts[] = 'EXCEPT';  | 
            ||
| 194 | $parts[] = 'SELECT v, w';  | 
            ||
| 195 | $parts[] = 'FROM sec';  | 
            ||
| 196 | |||
| 197 | $expectedSql = implode(PHP_EOL, $parts);  | 
            ||
| 198 | |||
| 199 | $this->assertSame($expectedSql, $sql);  | 
            ||
| 200 | }  | 
            ||
| 212 |