| Conditions | 7 |
| Paths | 14 |
| Total Lines | 89 |
| Code Lines | 80 |
| 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 namespace XoopsModules\Xfguestbook; |
||
| 78 | public function insert(\XoopsObject $msg) |
||
| 79 | { |
||
| 80 | if (Message::class !== get_class($msg)) { |
||
| 81 | return false; |
||
| 82 | } |
||
| 83 | if (!$msg->cleanVars()) { |
||
| 84 | return false; |
||
| 85 | } |
||
| 86 | foreach ($msg->cleanVars as $k => $v) { |
||
| 87 | ${$k} = $v; |
||
| 88 | } |
||
| 89 | if (empty($msg_id)) { |
||
| 90 | $msg_id = $this->db->genId('xfguestbook_msg_msg_id_seq'); |
||
| 91 | $sql = 'INSERT INTO ' |
||
| 92 | . $this->db->prefix('xfguestbook_msg') |
||
| 93 | . ' (msg_id, user_id, uname, title, message, note, post_time, email, url, poster_ip, moderate, gender, country, photo, flagdir, other) VALUES (' |
||
| 94 | . $msg_id |
||
| 95 | . ',' |
||
| 96 | . $user_id |
||
| 97 | . ', ' |
||
| 98 | . $this->db->quoteString($uname) |
||
| 99 | . ', ' |
||
| 100 | . $this->db->quoteString($title) |
||
| 101 | . ', ' |
||
| 102 | . $this->db->quoteString($message) |
||
| 103 | . ', ' |
||
| 104 | . $this->db->quoteString($note) |
||
| 105 | . ', ' |
||
| 106 | . $post_time |
||
| 107 | . ', ' |
||
| 108 | . $this->db->quoteString($email) |
||
| 109 | . ', ' |
||
| 110 | . $this->db->quoteString($url) |
||
| 111 | . ', ' |
||
| 112 | . $this->db->quoteString($poster_ip) |
||
| 113 | . ', ' |
||
| 114 | . $moderate |
||
| 115 | . ', ' |
||
| 116 | . $this->db->quoteString($gender) |
||
| 117 | . ', ' |
||
| 118 | . $this->db->quoteString($country) |
||
| 119 | . ', ' |
||
| 120 | . $this->db->quoteString($photo) |
||
| 121 | . ', ' |
||
| 122 | . $this->db->quoteString($flagdir) |
||
| 123 | . ', ' |
||
| 124 | . $this->db->quoteString($other) |
||
| 125 | . ')'; |
||
| 126 | } else { |
||
| 127 | $sql = 'UPDATE ' |
||
| 128 | . $this->db->prefix('xfguestbook_msg') |
||
| 129 | . ' SET user_id=' |
||
| 130 | . $user_id |
||
| 131 | . ', uname=' |
||
| 132 | . $this->db->quoteString($uname) |
||
| 133 | . ', title=' |
||
| 134 | . $this->db->quoteString($title) |
||
| 135 | . ', message=' |
||
| 136 | . $this->db->quoteString($message) |
||
| 137 | . ', note=' |
||
| 138 | . $this->db->quoteString($note) |
||
| 139 | . ', email=' |
||
| 140 | . $this->db->quoteString($email) |
||
| 141 | . ', url=' |
||
| 142 | . $this->db->quoteString($url) |
||
| 143 | . ', moderate=' |
||
| 144 | . $moderate |
||
| 145 | . ', gender=' |
||
| 146 | . $this->db->quoteString($gender) |
||
| 147 | . ', country=' |
||
| 148 | . $this->db->quoteString($country) |
||
| 149 | . ', photo=' |
||
| 150 | . $this->db->quoteString($photo) |
||
| 151 | . ', flagdir=' |
||
| 152 | . $this->db->quoteString($flagdir) |
||
| 153 | . ', other=' |
||
| 154 | . $this->db->quoteString($other) |
||
| 155 | . ' WHERE msg_id=' |
||
| 156 | . $msg_id; |
||
| 157 | } |
||
| 158 | if (!$result = $this->db->queryF($sql)) { |
||
| 159 | return false; |
||
| 160 | } |
||
| 161 | if (empty($msg_id)) { |
||
| 162 | $msg_id = $this->db->getInsertId(); |
||
| 163 | } |
||
| 164 | $msg->assignVar('msg_id', $msg_id); |
||
| 165 | |||
| 166 | return $msg_id; |
||
| 167 | } |
||
| 305 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.