Conditions | 2 |
Paths | 2 |
Total Lines | 51 |
Code Lines | 24 |
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 | 'title', |
||
46 | 'content', |
||
47 | ], |
||
48 | 'required' |
||
49 | ], |
||
50 | [ |
||
51 | [ |
||
52 | 'description', |
||
53 | 'content', |
||
54 | ], |
||
55 | 'string' |
||
56 | ], |
||
57 | [ |
||
58 | [ |
||
59 | 'title', |
||
60 | 'metaKeys', |
||
61 | ], |
||
62 | 'string', |
||
63 | 'max' => 128 |
||
64 | ], |
||
65 | [ |
||
66 | [ |
||
67 | 'metaDescription', |
||
68 | ], |
||
69 | 'string', |
||
70 | 'max' => 255 |
||
71 | ], |
||
72 | [ |
||
73 | [ |
||
74 | 'default' |
||
75 | ], |
||
76 | 'integer' |
||
77 | ], |
||
78 | [ |
||
79 | 'title', |
||
80 | 'unique', |
||
81 | 'skipOnError' => true, |
||
82 | 'targetClass' => static::class, |
||
83 | 'filter' => $this->getScenario() == self::SCENARIO_UPDATE ? 'id != '.$this->id : '' |
||
84 | ], |
||
85 | [ |
||
86 | [ |
||
87 | 'created_at', |
||
88 | 'updated_at' |
||
89 | ], |
||
90 | 'safe' |
||
91 | ], |
||
212 |