| Conditions | 1 |
| Paths | 1 |
| Total Lines | 88 |
| Code Lines | 50 |
| 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 |
||
| 65 | public static function getAliasesProvider(): array |
||
| 66 | { |
||
| 67 | return [ |
||
| 68 | [ |
||
| 69 | 'select * from (select 1) tbl', |
||
| 70 | 'mydb', |
||
| 71 | [], |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | 'select i.name as `n`,abcdef gh from qwerty i', |
||
| 75 | 'mydb', |
||
| 76 | [ |
||
| 77 | 'mydb' => [ |
||
| 78 | 'alias' => null, |
||
| 79 | 'tables' => [ |
||
| 80 | 'qwerty' => [ |
||
| 81 | 'alias' => 'i', |
||
| 82 | 'columns' => [ |
||
| 83 | 'name' => 'n', |
||
| 84 | 'abcdef' => 'gh', |
||
| 85 | ], |
||
| 86 | ], |
||
| 87 | ], |
||
| 88 | ], |
||
| 89 | ], |
||
| 90 | ], |
||
| 91 | [ |
||
| 92 | 'select film_id id,title from film', |
||
| 93 | 'sakila', |
||
| 94 | [ |
||
| 95 | 'sakila' => [ |
||
| 96 | 'alias' => null, |
||
| 97 | 'tables' => [ |
||
| 98 | 'film' => [ |
||
| 99 | 'alias' => null, |
||
| 100 | 'columns' => ['film_id' => 'id'], |
||
| 101 | ], |
||
| 102 | ], |
||
| 103 | ], |
||
| 104 | ], |
||
| 105 | ], |
||
| 106 | [ |
||
| 107 | 'select `sakila`.`A`.`actor_id` as aid,`F`.`film_id` `fid`,' |
||
| 108 | . 'last_update updated from `sakila`.actor A join `film_actor` as ' |
||
| 109 | . '`F` on F.actor_id = A.`actor_id`', |
||
| 110 | 'sakila', |
||
| 111 | [ |
||
| 112 | 'sakila' => [ |
||
| 113 | 'alias' => null, |
||
| 114 | 'tables' => [ |
||
| 115 | 'film_actor' => [ |
||
| 116 | 'alias' => 'F', |
||
| 117 | 'columns' => [ |
||
| 118 | 'film_id' => 'fid', |
||
| 119 | 'last_update' => 'updated', |
||
| 120 | ], |
||
| 121 | ], |
||
| 122 | 'actor' => [ |
||
| 123 | 'alias' => 'A', |
||
| 124 | 'columns' => [ |
||
| 125 | 'actor_id' => 'aid', |
||
| 126 | 'last_update' => 'updated', |
||
| 127 | ], |
||
| 128 | ], |
||
| 129 | ], |
||
| 130 | ], |
||
| 131 | ], |
||
| 132 | ], |
||
| 133 | [ |
||
| 134 | 'SELECT film_id FROM (SELECT * FROM film) as f;', |
||
| 135 | 'sakila', |
||
| 136 | [], |
||
| 137 | ], |
||
| 138 | [ |
||
| 139 | 'SELECT 1', |
||
| 140 | '', |
||
| 141 | [], |
||
| 142 | ], |
||
| 143 | [ |
||
| 144 | 'SELECT * FROM orders AS ord WHERE 1', |
||
| 145 | 'db', |
||
| 146 | [ |
||
| 147 | 'db' => [ |
||
| 148 | 'alias' => null, |
||
| 149 | 'tables' => [ |
||
| 150 | 'orders' => [ |
||
| 151 | 'alias' => 'ord', |
||
| 152 | 'columns' => [], |
||
| 153 | ], |
||
| 161 |