Conditions | 2 |
Paths | 2 |
Total Lines | 62 |
Code Lines | 51 |
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 |
||
71 | public function getLatestSubmissions($user_id = null, $last_timestamp = null, $action = null, $done = null) { |
||
72 | $stmt = \AL\Db\execute_query( |
||
73 | "GameSubmissionDAO: getLatestSubmissions", |
||
74 | $this->mysqli, |
||
75 | $this->getGameSubmissionQuery($user_id, $last_timestamp, $action, $done), |
||
76 | null, null |
||
77 | ); |
||
78 | |||
79 | \AL\Db\bind_result( |
||
80 | "GameSubmissionDAO: getLatestSubmissions", |
||
81 | $stmt, |
||
82 | $game_id, |
||
83 | $game_name, |
||
|
|||
84 | $timestamp, |
||
85 | $date, |
||
86 | $comment, |
||
87 | $submission_id, |
||
88 | $done, |
||
89 | $userid, |
||
90 | $username, |
||
91 | $email, |
||
92 | $join_date, |
||
93 | $karma, |
||
94 | $show_email, |
||
95 | $avatar_ext, |
||
96 | $user_subm_count, |
||
97 | $user_comment_count |
||
98 | ); |
||
99 | |||
100 | $submissions = []; |
||
101 | while ($stmt->fetch()) { |
||
102 | $comment = nl2br($comment); |
||
103 | $comment = InsertALCode($comment); |
||
104 | $comment = trim($comment); |
||
105 | $comment = RemoveSmillies($comment); |
||
106 | |||
107 | $submission = new \AL\Common\Model\GameSubmission\GameSubmission( |
||
108 | $game_id, |
||
109 | $game_name, |
||
110 | $timestamp, |
||
111 | $date, |
||
112 | $comment, |
||
113 | $submission_id, |
||
114 | $done, |
||
115 | $userid, |
||
116 | $username, |
||
117 | $email, |
||
118 | $join_date, |
||
119 | $karma, |
||
120 | $show_email, |
||
121 | $avatar_ext, |
||
122 | $user_subm_count, |
||
123 | $user_comment_count, |
||
124 | null |
||
125 | ); |
||
126 | |||
127 | $submissions[] = $submission; |
||
128 | } |
||
129 | |||
130 | $stmt->close(); |
||
131 | |||
132 | return $submissions; |
||
133 | } |
||
227 |