| Conditions | 9 |
| Paths | 160 |
| Total Lines | 82 |
| 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 |
||
| 166 | public function asJskos($queryExVocabs = true, $lang = null, $hrefLink = null) |
||
| 167 | { |
||
| 168 | $propertyLabel = $this->getLabel($lang, $queryExVocabs); |
||
| 169 | $propertyLang = $lang; |
||
| 170 | if (!is_string($propertyLabel)) { |
||
| 171 | $propertyLang = $propertyLabel->getLang(); |
||
| 172 | $propertyLabel = $propertyLabel->getValue(); |
||
| 173 | } |
||
| 174 | $ret = [ |
||
| 175 | // JSKOS |
||
| 176 | 'uri' => $this->source->getUri(), |
||
| 177 | 'notation' => $this->getNotation(), |
||
| 178 | 'type' => [$this->type], |
||
| 179 | 'prefLabel' => $propertyLabel, |
||
| 180 | 'from' => [ |
||
| 181 | 'memberSet' => [ |
||
| 182 | [ |
||
| 183 | 'uri' => (string) $this->source->getUri(), |
||
| 184 | ] |
||
| 185 | ] |
||
| 186 | ], |
||
| 187 | 'to' => [ |
||
| 188 | 'memberSet' => [ |
||
| 189 | [ |
||
| 190 | 'uri' => (string) $this->getUri() |
||
| 191 | ] |
||
| 192 | ] |
||
| 193 | ], |
||
| 194 | // EXTRA |
||
| 195 | 'hrefLink' => $hrefLink, // link to resource as displayed in the UI |
||
| 196 | 'lang' => $propertyLang, // TBD: could it be part of the prefLabel? |
||
| 197 | 'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI |
||
| 198 | 'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch |
||
| 199 | ]; |
||
| 200 | |||
| 201 | $helpprop = $this->type . "_help"; |
||
| 202 | // see if we have a translation for the property help text |
||
| 203 | $help = gettext($helpprop); |
||
| 204 | if ($help != $helpprop) { |
||
| 205 | $ret['description'] = $help; |
||
| 206 | } |
||
| 207 | |||
| 208 | $fromScheme = $this->vocab->getDefaultConceptScheme(); |
||
| 209 | if (isset($fromScheme)) { |
||
| 210 | $ret['fromScheme'] = [ |
||
| 211 | 'uri' => (string) $fromScheme, |
||
| 212 | ]; |
||
| 213 | } |
||
| 214 | |||
| 215 | $exvocab = $this->getExvocab(); |
||
| 216 | if (isset($exvocab)) { |
||
| 217 | $ret['toScheme'] = [ |
||
| 218 | 'uri' => (string) $exvocab->getDefaultConceptScheme(), |
||
| 219 | ]; |
||
| 220 | } |
||
| 221 | |||
| 222 | $notation = $this->getNotation(); |
||
| 223 | if (isset($notation)) { |
||
| 224 | $ret['to']['memberSet'][0]['notation'] = (string) $notation; |
||
| 225 | } |
||
| 226 | |||
| 227 | $label = $this->getLabel($lang, $queryExVocabs); |
||
| 228 | if (isset($label)) { |
||
| 229 | if (is_string($label)) { |
||
| 230 | list($labelLang, $labelValue) = ['', $label]; |
||
| 231 | } else { |
||
| 232 | list($labelLang, $labelValue) = [$label->getLang(), $label->getValue()]; |
||
| 233 | } |
||
| 234 | // set the language of the preferred label to be whatever returned |
||
| 235 | $ret['lang'] = $labelLang; |
||
| 236 | |||
| 237 | if ($labelValue != $this->getUri()) { |
||
| 238 | // The `queryLabel()` method above will fallback to returning the URI |
||
| 239 | // if no label was found. We don't want that here. |
||
| 240 | $ret['to']['memberSet'][0]['prefLabel'] = [ |
||
| 241 | $labelLang => $labelValue, |
||
| 242 | ]; |
||
| 243 | } |
||
| 244 | } |
||
| 245 | |||
| 246 | return $ret; |
||
| 247 | } |
||
| 248 | |||
| 251 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.