Conditions | 1 |
Paths | 1 |
Total Lines | 51 |
Code Lines | 33 |
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 |
||
22 | public function schema() |
||
23 | { |
||
24 | return [ |
||
25 | '_id' => [ |
||
26 | 'unique' => true, |
||
27 | 'validator' => [ |
||
28 | 'class' => StringValidator::class, |
||
29 | ] |
||
30 | ], |
||
31 | 'title' => [ |
||
32 | 'unique' => true, |
||
33 | 'required' => true, |
||
34 | 'validator' => [ |
||
35 | 'class' => StringValidator::class, |
||
36 | 'params' => [ |
||
37 | 'maxLength' => 100, |
||
38 | ], |
||
39 | ], |
||
40 | ], |
||
41 | 'other' => [ |
||
42 | 'unique' => true, |
||
43 | 'validator' => [ |
||
44 | 'class' => StringValidator::class, |
||
45 | 'params' => [ |
||
46 | 'maxLength' => 100, |
||
47 | ], |
||
48 | ], |
||
49 | ], |
||
50 | 'noindex' => [ |
||
51 | 'unique' => true, |
||
52 | 'validator' => [ |
||
53 | 'class' => StringValidator::class, |
||
54 | 'params' => [ |
||
55 | 'maxLength' => 100, |
||
56 | ], |
||
57 | ], |
||
58 | ], |
||
59 | 'status' => [ |
||
60 | 'validator' => [ |
||
61 | 'class' => IntegerValidator::class, |
||
62 | 'params' => [ |
||
63 | 'min' => 0, |
||
64 | 'max' => 1, |
||
65 | ], |
||
66 | ], |
||
67 | ], |
||
68 | 'bar' => [ |
||
69 | 'type' => BarSchema::class, |
||
70 | ], |
||
71 | ]; |
||
72 | } |
||
73 | } |
||
74 |