| Conditions | 1 |
| Paths | 1 |
| Total Lines | 79 |
| Code Lines | 38 |
| 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 |
||
| 40 | public function rules() |
||
| 41 | { |
||
| 42 | return [ |
||
| 43 | [ |
||
| 44 | [ |
||
| 45 | 'contacts_id', |
||
| 46 | 'language_id' |
||
| 47 | ], |
||
| 48 | 'required' |
||
| 49 | ], |
||
| 50 | [ |
||
| 51 | [ |
||
| 52 | 'contacts_id', |
||
| 53 | 'language_id' |
||
| 54 | ], |
||
| 55 | 'integer' |
||
| 56 | ], |
||
| 57 | [ |
||
| 58 | [ |
||
| 59 | 'created_at', |
||
| 60 | 'updated_at' |
||
| 61 | ], |
||
| 62 | 'safe' |
||
| 63 | ], |
||
| 64 | [ |
||
| 65 | [ |
||
| 66 | 'title', |
||
| 67 | 'metaKeys', |
||
| 68 | 'metaDescription' |
||
| 69 | ], |
||
| 70 | 'string', |
||
| 71 | 'max' => 255 |
||
| 72 | ], |
||
| 73 | [ |
||
| 74 | [ |
||
| 75 | 'address' |
||
| 76 | ], |
||
| 77 | 'string', |
||
| 78 | 'max' => 128 |
||
| 79 | ], |
||
| 80 | [ |
||
| 81 | [ |
||
| 82 | 'email' |
||
| 83 | ], |
||
| 84 | 'string', |
||
| 85 | 'max' => 128 |
||
| 86 | ], |
||
| 87 | [ |
||
| 88 | [ |
||
| 89 | 'phone' |
||
| 90 | ], |
||
| 91 | 'string', |
||
| 92 | 'max' => 128 |
||
| 93 | ], |
||
| 94 | [ |
||
| 95 | [ |
||
| 96 | 'contacts_id', |
||
| 97 | 'language_id' |
||
| 98 | ], |
||
| 99 | 'unique', |
||
| 100 | 'targetAttribute' => ['contacts_id', 'language_id'] |
||
| 101 | ], |
||
| 102 | [ |
||
| 103 | [ |
||
| 104 | 'contacts_id' |
||
| 105 | ], |
||
| 106 | 'exist', |
||
| 107 | 'skipOnError' => true, |
||
| 108 | 'targetClass' => Contact::class, |
||
| 109 | 'targetAttribute' => ['contacts_id' => 'id'] |
||
| 110 | ], |
||
| 111 | [ |
||
| 112 | [ |
||
| 113 | 'language_id' |
||
| 114 | ], |
||
| 115 | 'exist', |
||
| 116 | 'skipOnError' => true, |
||
| 117 | 'targetClass' => Language::class, |
||
| 118 | 'targetAttribute' => ['language_id' => 'id'] |
||
| 119 | ], |
||
| 162 |