| Conditions | 10 |
| Paths | 10 |
| Total Lines | 31 |
| Code Lines | 18 |
| 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 |
||
| 17 | protected function generateRelations() |
||
| 18 | { |
||
| 19 | $tables = parent::generateRelations(); |
||
| 20 | |||
| 21 | foreach ($tables as $tableName => &$relations) { |
||
| 22 | foreach ($relations as $relationName => $relationConfig) { |
||
| 23 | if (in_array($relationConfig[1], $this->ignoreRelations)) { |
||
| 24 | unset($relations[$relationName]); |
||
| 25 | } |
||
| 26 | |||
| 27 | // hardcoded fix for https://github.com/yiisoft/yii2-gii/issues/55. |
||
| 28 | if ( |
||
| 29 | $tableName === 'oauth2_user_client_scope' |
||
| 30 | && $relationName === 'User' |
||
| 31 | && $relationConfig[1] === 'Oauth2UserClient' |
||
| 32 | ) { |
||
| 33 | $relations['UserClient'] = $relations['User']; |
||
| 34 | unset($relations['User']); |
||
| 35 | } |
||
| 36 | if ( |
||
| 37 | $tableName === 'oauth2_scope' |
||
| 38 | && $relationName === 'Users' |
||
| 39 | && $relationConfig[1] === 'Oauth2UserClient' |
||
| 40 | ) { |
||
| 41 | $relations['UserClients'] = $relations['Users']; |
||
| 42 | unset($relations['Users']); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | return $tables; |
||
| 48 | } |
||
| 81 |