Conditions | 1 |
Paths | 1 |
Total Lines | 82 |
Code Lines | 10 |
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 |
||
49 | public function dataValidationPassed(): array |
||
50 | { |
||
51 | return [ |
||
52 | // JSON test from http://www.json.org/JSON_checker/test/pass1.json |
||
53 | [ |
||
54 | <<<'JSON_WRAP' |
||
55 | [ |
||
56 | "JSON Test Pattern pass1", |
||
57 | {"object with 1 member":["array with 1 element"]}, |
||
58 | {}, |
||
59 | [], |
||
60 | -42, |
||
61 | true, |
||
62 | false, |
||
63 | null, |
||
64 | { |
||
65 | "integer": 1234567890, |
||
66 | "real": -9876.543210, |
||
67 | "e": 0.123456789e-12, |
||
68 | "E": 1.234567890E+34, |
||
69 | "": 23456789012E66, |
||
70 | "zero": 0, |
||
71 | "one": 1, |
||
72 | "space": " ", |
||
73 | "quote": "\"", |
||
74 | "backslash": "\\", |
||
75 | "controls": "\b\f\n\r\t", |
||
76 | "slash": "/ & \/", |
||
77 | "alpha": "abcdefghijklmnopqrstuvwyz", |
||
78 | "ALPHA": "ABCDEFGHIJKLMNOPQRSTUVWYZ", |
||
79 | "digit": "0123456789", |
||
80 | "0123456789": "digit", |
||
81 | "special": "`1~!@#$%^&*()_+-={':[,]}|;.</>?", |
||
82 | "hex": "\u0123\u4567\u89AB\uCDEF\uabcd\uef4A", |
||
83 | "true": true, |
||
84 | "false": false, |
||
85 | "null": null, |
||
86 | "array":[ ], |
||
87 | "object":{ }, |
||
88 | "address": "50 St. James Street", |
||
89 | "url": "http://www.JSON.org/", |
||
90 | "comment": "// /* <!-- --", |
||
91 | "# -- --> */": " ", |
||
92 | " s p a c e d " :[1,2 , 3 |
||
93 | |||
94 | , |
||
95 | |||
96 | 4 , 5 , 6 ,7 ],"compact":[1,2,3,4,5,6,7], |
||
97 | "jsontext": "{\"object with 1 member\":[\"array with 1 element\"]}", |
||
98 | "quotes": "" \u0022 %22 0x22 034 "", |
||
99 | "\/\\\"\uCAFE\uBABE\uAB98\uFCDE\ubcda\uef4A\b\f\n\r\t`1~!@#$%^&*()_+-=[]{}|;:',./<>?" |
||
100 | : "A key can be any string" |
||
101 | }, |
||
102 | 0.5 ,98.6 |
||
103 | , |
||
104 | 99.44 |
||
105 | , |
||
106 | |||
107 | 1066, |
||
108 | 1e1, |
||
109 | 0.1e1, |
||
110 | 1e-1, |
||
111 | 1e00,2e+00,2e-00 |
||
112 | ,"rosebud"] |
||
113 | JSON_WRAP |
||
114 | , |
||
115 | [new Json()], |
||
116 | ], |
||
117 | // JSON test from http://www.json.org/JSON_checker/test/pass2.json |
||
118 | ['[[[[[[[[[[[[[[[[[[["Not too deep"]]]]]]]]]]]]]]]]]]]', [new Json()]], |
||
119 | // JSON test from http://www.json.org/JSON_checker/test/pass3.json |
||
120 | [ |
||
121 | <<<'JSON_WRAP' |
||
122 | { |
||
123 | "JSON Test Pattern pass3": { |
||
124 | "The outermost value": "must be an object or array.", |
||
125 | "In this test": "It is an object." |
||
126 | } |
||
127 | } |
||
128 | JSON_WRAP |
||
129 | , |
||
130 | [new Json()], |
||
131 | ], |
||
193 |