Conditions | 2 |
Paths | 2 |
Total Lines | 78 |
Code Lines | 61 |
Lines | 0 |
Ratio | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 3 |
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 |
||
37 | private static function desc($errCode) |
||
38 | { |
||
39 | $errDesc=[ |
||
40 | |||
41 | '200' => "Successful", |
||
42 | '201' => "Partially Successful", |
||
43 | '403' => "Forbidden", |
||
44 | '451' => "Unavailable For Legal Reasons", |
||
45 | |||
46 | '1000' => "Unspecified Response", /** Under normal condictions those errors shouldn't been displayed to end users |
||
47 | * unless they attempt to do so, some submissions should be intercepted |
||
48 | * by the frontend before the request sended |
||
49 | */ |
||
50 | '1001' => "Internal Sever Error", |
||
51 | '1002' => "Service Currently Unavailable", |
||
52 | '1003' => "Missing Params", |
||
53 | '1004' => "Write/Read Permission Denied", |
||
54 | '1005' => "Invalid File", |
||
55 | '1006' => "Invalid length params", |
||
56 | '1007' => "Invalid parameter passed", |
||
57 | '1984' => "Ignorance is Strength", |
||
58 | |||
59 | '2000' => "Account-Related Error", |
||
60 | '2001' => "Permission Denied", |
||
61 | '2002' => "Please Login First", |
||
62 | '2003' => "A user with the same username already exists", |
||
63 | '2004' => "New passwords do not match", |
||
64 | '2005' => "Old passwords error", |
||
65 | '2006' => "Can't find this user", |
||
66 | |||
67 | '3000' => "Problem-Related Error", |
||
68 | '3001' => "Problem Not Found", |
||
69 | '3002' => "Submission Size Limit Exceed(64kb max)", |
||
70 | '3003' => "Duplicate Problem Solution Submitted", |
||
71 | '3004' => "Certain Problem Solution not Operatable", |
||
72 | '3005' => "Copper", // Reserved for Copper in memory of OASIS and those who contributed a lot |
||
73 | |||
74 | '4000' => "Contest-Related Error", |
||
75 | '4001' => "Contest Not Found", |
||
76 | '4002' => "Too Much Problems", |
||
77 | '4003' => "No Need for Registration", |
||
78 | '4004' => "Registration Ended", |
||
79 | '4005' => "Registration Denied", |
||
80 | '4006' => "AlreadyRegistered", |
||
81 | '4007' => "A contest cannot be both a public and a practice contest", |
||
82 | '4008' => "The contest is not over.", |
||
83 | '4009' => 'Only freeze contest can join scrollboard', |
||
84 | '4010' => 'Contest Still Under Judging.', |
||
85 | |||
86 | '5000' => "Status-Related Error", |
||
87 | '5001' => "Status Not Found", |
||
88 | |||
89 | '6000' => "Submission-Related Error", |
||
90 | '6001' => "Cannot Find Available Judgers", |
||
91 | '6002' => "Sharing Method Not Allowed", |
||
92 | '6003' => "No Need to Resubmit", |
||
93 | |||
94 | '7000' => "Group-Related Error", |
||
95 | '7001' => "Group Not Found", |
||
96 | '7002' => "Insufficient Clearance", |
||
97 | '7003' => "No Need to Approve", |
||
98 | '7004' => "Group Member Not Found", |
||
99 | '7005' => "Don't play just for fun",//gcode=="create" |
||
100 | '7006' => "A group with the same gcode already exists", |
||
101 | '7007' => "Group Problem Tag Exist", |
||
102 | '7008' => "The group leader cannot leave the group", |
||
103 | |||
104 | '8000' => "Job-Related Error", |
||
105 | '8001' => "Job Still Running", |
||
106 | |||
107 | '9000' => "Abuse-Related Error", |
||
108 | '9001' => "Abuse Invalid", |
||
109 | |||
110 | '10000' => "Dojo-Related Error", |
||
111 | '10001' => "Dojo Cannot Complete", |
||
112 | '10002' => "Dojo Not Found", |
||
113 | ]; |
||
114 | return isset($errDesc[$errCode]) ? $errDesc[$errCode] : $errDesc['1000']; |
||
115 | } |
||
117 |