Conditions | 28 |
Paths | > 20000 |
Total Lines | 188 |
Code Lines | 76 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
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 |
||
109 | public function getContent(&$exp): string |
||
110 | { |
||
111 | $rdf = '<' . $this->type . " rdf:about=\"" . clean($this->url, true) . "\">\n"; |
||
112 | if ($this->subject) { |
||
113 | $rdf .= " <dc:title>" . clean($this->subject) . "</dc:title>\n"; |
||
114 | // if(strcmp($this->has_container, 'http://en.wikipedia.org')===0) |
||
115 | // $rdf .= " <foaf:primaryTopic rdf:resource=\"".clean('http://dbpedia.org/resource/' |
||
116 | // .$this->subject)."\"/>\n"; |
||
117 | } |
||
118 | |||
119 | $creator_name = null; |
||
120 | |||
121 | if (count($this->contributors) > 0) { |
||
122 | foreach ($this->contributors as $cont_id => $cont_name) { |
||
123 | if (!isset($this->creator['sioc:modifier']) || ($this->creator['sioc:modifier'] != $cont_id)) { |
||
124 | $rdf .= " <sioc:has_modifier rdf:resource=\"" . normalizeUri( |
||
|
|||
125 | $exp->siocURL('user', $cont_id) |
||
126 | ) . "\" rdfs:label=\"" . clean($cont_name) . "\"/>\n"; |
||
127 | } |
||
128 | } |
||
129 | |||
130 | if (isset($this->contributors[$this->creator['sioc:modifier']])) { |
||
131 | $creator_name = 'rdfs:label="' . clean($this->contributors[$this->creator['sioc:modifier']]) . '"'; |
||
132 | } |
||
133 | } |
||
134 | |||
135 | if (is_array($this->creator)) { |
||
136 | // if ($this->creator['foaf:maker']) |
||
137 | // $rdf .= " <foaf:maker rdf:resource=\"".clean($this->creator['foaf:maker'])."\"/>\n"; |
||
138 | if ($this->creator['sioc:modifier']) { |
||
139 | if ($this->is_creator === false) { |
||
140 | $rdf .= " <sioc:has_modifier rdf:resource=\"" . normalizeUri( |
||
141 | $exp->siocURL('user', $this->creator['sioc:modifier']) |
||
142 | ) . "\" $creator_name/>\n"; |
||
143 | } |
||
144 | if ($this->is_creator === true) { |
||
145 | $rdf .= " <sioc:has_creator rdf:resource=\"" . normalizeUri( |
||
146 | $exp->siocURL('user', $this->creator['sioc:modifier']) |
||
147 | ) . "\" $creator_name/>\n"; |
||
148 | } |
||
149 | } |
||
150 | } |
||
151 | |||
152 | if ($this->created) { |
||
153 | $rdf .= " <dcterms:created>" . $this->created . "</dcterms:created>\n"; |
||
154 | } |
||
155 | |||
156 | if ($this->modified) { |
||
157 | $rdf .= " <dcterms:modified>" . $this->modified . "</dcterms:modified>\n"; |
||
158 | } |
||
159 | |||
160 | if ($this->has_space) { |
||
161 | $rdf .= " <sioc:has_space rdf:resource=\"" . clean($this->has_space, true) . "\" />\n"; |
||
162 | // TODO: rdfs:label |
||
163 | } |
||
164 | |||
165 | if ($this->has_container) { |
||
166 | $rdf .= " <sioc:has_container rdf:resource=\"" . normalizeUri( |
||
167 | $exp->siocURL('container', $this->has_container) |
||
168 | ) . "\" />\n"; |
||
169 | // TODO: rdfs:label |
||
170 | } |
||
171 | |||
172 | if ($this->content) { |
||
173 | $rdf .= " <sioc:content><![CDATA[" . pureContent($this->content) . "]]></sioc:content>\n"; |
||
174 | } |
||
175 | |||
176 | if ($this->content_encoded) { |
||
177 | $rdf .= " <content:encoded><![CDATA[" . $this->content_encoded . "]]></content:encoded>\n"; |
||
178 | } |
||
179 | |||
180 | /* |
||
181 | if(is_array($this->topics)) { |
||
182 | foreach($this->topics as $topic=>$url) { |
||
183 | $rdf .= " <sioc:topic>\n"; |
||
184 | $rdf .= " <sioct:Category rdf:about=\"" . clean($url) ."\">\n"; |
||
185 | $rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
||
186 | clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$url); |
||
187 | if ($this->api) $rdf .= clean("&api=" . $this->api); |
||
188 | $rdf .= "\"/>\n"; |
||
189 | $rdf .= " </sioct:Category>\n"; |
||
190 | $rdf .= " </sioc:topic>\n"; |
||
191 | } |
||
192 | } |
||
193 | */ |
||
194 | |||
195 | if (is_array($this->links) && count($this->links) > 0) { |
||
196 | foreach ($this->links as $link_id => $link_exists) { |
||
197 | if ($link_exists && !isHiddenPage($link_id)) { |
||
198 | $rdf .= " <sioc:links_to rdf:resource=\"" . normalizeUri( |
||
199 | $exp->siocURL('post', $link_id) |
||
200 | ) . "\"/>\n"; |
||
201 | // TODO: rdfs:label |
||
202 | } |
||
203 | } |
||
204 | } |
||
205 | |||
206 | if (count($this->backlinks) > 0) { |
||
207 | foreach ($this->backlinks as $link_id) { |
||
208 | if (!isHiddenPage($link_id)) { |
||
209 | $rdf .= " <dcterms:isReferencedBy rdf:resource=\"" . normalizeUri( |
||
210 | $exp->siocURL('post', $link_id) |
||
211 | ) . "\"/>\n"; |
||
212 | // TODO: rdfs:label |
||
213 | } |
||
214 | } |
||
215 | } |
||
216 | |||
217 | /* |
||
218 | if(is_array($this->ext_links)) { |
||
219 | foreach($this->ext_links as $label=>$url) { |
||
220 | $rdf .= " <sioc:links_to rdf:resource=\"" . clean($url) ."\"/>\n"; |
||
221 | } |
||
222 | } |
||
223 | */ |
||
224 | |||
225 | if ($this->previous_version) { |
||
226 | $rdf .= " <sioc:previous_version rdf:resource=\"" . normalizeUri( |
||
227 | $exp->siocURL( |
||
228 | 'post', |
||
229 | $this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->previous_version |
||
230 | ) |
||
231 | ) . "\"/>\n"; |
||
232 | // TODO: rdfs:label |
||
233 | |||
234 | /* If there is support for inference and transitivity the following is not needed */ |
||
235 | $rdf .= " <sioc:earlier_version rdf:resource=\"" . normalizeUri( |
||
236 | $exp->siocURL( |
||
237 | 'post', |
||
238 | $this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->previous_version |
||
239 | ) |
||
240 | ) . "\"/>\n"; |
||
241 | // TODO: rdfs:label |
||
242 | |||
243 | } |
||
244 | |||
245 | if ($this->next_version) { |
||
246 | $rdf .= " <sioc:next_version rdf:resource=\"" . normalizeUri( |
||
247 | $exp->siocURL( |
||
248 | 'post', |
||
249 | $this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->next_version |
||
250 | ) |
||
251 | ) . "\"/>\n"; |
||
252 | // TODO: rdfs:label |
||
253 | |||
254 | /* If there is support for inference and transitivity the following is not needed */ |
||
255 | $rdf .= " <sioc:later_version rdf:resource=\"" . normalizeUri( |
||
256 | $exp->siocURL( |
||
257 | 'post', |
||
258 | $this->id . $exp->_urlseparator . 'rev' . $exp->_urlequal . $this->next_version |
||
259 | ) |
||
260 | ) . "\"/>\n"; |
||
261 | // TODO: rdfs:label |
||
262 | } |
||
263 | |||
264 | if ($this->latest_version) { |
||
265 | $rdf .= " <sioc:latest_version rdf:resource=\"" . normalizeUri( |
||
266 | $exp->siocURL('post', $this->id) |
||
267 | ) . "\"/>\n"; |
||
268 | // TODO: rdfs:label |
||
269 | } |
||
270 | |||
271 | /* |
||
272 | if($this->has_discussion && (strpos($this->has_discussion, 'Talk:Talk:') == FALSE)) { |
||
273 | $rdf .= " <sioc:has_discussion>\n"; |
||
274 | $rdf .= " <sioct:WikiArticle rdf:about=\"" . clean($this->has_discussion) ."\">\n"; |
||
275 | $rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
||
276 | clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$this->has_discussion); |
||
277 | if ($this->api) $rdf .= clean("&api=" . $this->api); |
||
278 | $rdf .= "\"/>\n"; |
||
279 | $rdf .= " </sioct:WikiArticle>\n"; |
||
280 | $rdf .= " </sioc:has_discussion>\n"; |
||
281 | } |
||
282 | */ |
||
283 | |||
284 | /* |
||
285 | if($this->redirpage) |
||
286 | { |
||
287 | $rdf .= " <owl:sameAs rdf:resource=\"" . clean($this->redirpage) ."\"/>\n"; |
||
288 | $rdf .= " <rdfs:seeAlso rdf:resource=\"" . |
||
289 | clean('http://ws.sioc-project.org/mediawiki/mediawiki.php?wiki='.$this->redirpage); |
||
290 | if ($this->api) $rdf .= clean("&api=" . $this->api); |
||
291 | $rdf .= "\"/>\n"; |
||
292 | } |
||
293 | */ |
||
294 | |||
295 | $rdf .= "</" . $this->type . ">\n"; |
||
296 | return $rdf; |
||
297 | } |
||
464 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.