Conditions | 1 |
Paths | 1 |
Total Lines | 65 |
Code Lines | 36 |
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 |
||
44 | public function rules() |
||
45 | { |
||
46 | return [ |
||
47 | [ |
||
48 | [ |
||
49 | 'name', |
||
50 | 'email', |
||
51 | 'subject', |
||
52 | 'message', |
||
53 | ], |
||
54 | 'required' |
||
55 | ], |
||
56 | [ |
||
57 | 'message', |
||
58 | 'string', |
||
59 | 'max' => 2048 |
||
60 | ], |
||
61 | [ |
||
62 | [ |
||
63 | 'name', |
||
64 | 'email' |
||
65 | ], |
||
66 | 'string', |
||
67 | 'max' => 64 |
||
68 | ], |
||
69 | [ |
||
70 | 'phone', |
||
71 | 'string', |
||
72 | 'max' => 32 |
||
73 | ], |
||
74 | [ |
||
75 | 'subject', |
||
76 | 'string', |
||
77 | 'max' => 255 |
||
78 | ], |
||
79 | [ |
||
80 | 'email', |
||
81 | 'email' |
||
82 | ], |
||
83 | [ |
||
84 | 'read', |
||
85 | 'integer' |
||
86 | ], |
||
87 | [ |
||
88 | [ |
||
89 | 'created_at', |
||
90 | 'updated_at', |
||
91 | ], |
||
92 | 'safe', |
||
93 | ], |
||
94 | [ |
||
95 | 'verifyCode', |
||
96 | 'captcha', |
||
97 | 'on' => [ |
||
98 | self::SCENARIO_CONTACT |
||
99 | ], |
||
100 | 'captchaAction' => 'contact/captcha' |
||
101 | ], |
||
102 | [ |
||
103 | 'verifyCode', |
||
104 | 'captcha', |
||
105 | 'on' => [ |
||
106 | self::SCENARIO_FEEDBACK |
||
107 | ], |
||
108 | 'captchaAction' => 'feedback/captcha' |
||
109 | ] |
||
192 |