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