Passed
Pull Request — master (#1201)
by
unknown
03:26
created
model/Concept.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
                 return $this->resource->label($fallback);
137 137
             }
138 138
             // We need to check all the labels in case one of them matches a subtag of the current language
139
-            foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
139
+            foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
140 140
                 // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
141
-                if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) {
141
+                if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) {
142 142
                     return EasyRdf\Literal::create($label, $fallback);
143 143
                 }
144 144
             }
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 
160 160
     public function hasXlLabel($prop = 'prefLabel')
161 161
     {
162
-        if ($this->resource->hasProperty('skosxl:' . $prop)) {
162
+        if ($this->resource->hasProperty('skosxl:'.$prop)) {
163 163
             return true;
164 164
         }
165 165
         return false;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
     public function getXlLabel()
169 169
     {
170 170
         $labels = $this->resource->allResources('skosxl:prefLabel');
171
-        foreach($labels as $labres) {
171
+        foreach ($labels as $labres) {
172 172
             $label = $labres->getLiteral('skosxl:literalForm');
173 173
             if ($label !== null && $label->getLang() == $this->clang) {
174 174
                 return new LabelSkosXL($this->model, $labres);
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
         // catch external subjects that have $res as object
276 276
         $extSubjects = $exGraph->resourcesMatching("schema:about", $res);
277 277
 
278
-        $propList =  array_unique(array_merge(
278
+        $propList = array_unique(array_merge(
279 279
             $this->DEFAULT_EXT_PROPERTIES,
280 280
             $this->getVocab()->getConfig()->getExtProperties(),
281 281
             $this->getVocab()->getConfig()->getPluginRegister()->getExtProperties()
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
      * @param string[] $seen Processed resources so far
301 301
      * @param string[] $props (optional) limit to these property URIs
302 302
      */
303
-    private function addExternalTriplesToGraph($res, &$seen, $props=null)
303
+    private function addExternalTriplesToGraph($res, &$seen, $props = null)
304 304
     {
305 305
         if (array_key_exists($res->getUri(), $seen) && $seen[$res->getUri()] === 0) {
306 306
             return;
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
      */
331 331
     private function addPropertyValues($res, $prop, &$seen)
332 332
     {
333
-        $resList = $res->allResources('<' . $prop . '>');
333
+        $resList = $res->allResources('<'.$prop.'>');
334 334
 
335 335
         foreach ($resList as $res2) {
336 336
             if ($res2->isBNode()) {
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
             $this->addResourceReifications($res, $prop, $res2, $seen);
341 341
         }
342 342
 
343
-        $litList = $res->allLiterals('<' . $prop . '>');
343
+        $litList = $res->allLiterals('<'.$prop.'>');
344 344
 
345 345
         foreach ($litList as $lit) {
346 346
             $this->graph->addLiteral($res, $prop, $lit);
@@ -528,15 +528,15 @@  discard block
 block discarded – undo
528 528
                 // if not found in current vocabulary, look up in the default graph to be able
529 529
                 // to read an ontology loaded in a separate graph
530 530
                 // note that this imply that the property has an rdf:type declared for the query to work
531
-                if(!$is_well_known && !$proplabel) {
531
+                if (!$is_well_known && !$proplabel) {
532 532
                     $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang());
533 533
                     
534 534
                     $defaultPropLabel = $this->model->getDefaultSparql()->queryLabel($longUri, '');
535 535
 
536
-					if($envLangLabels) {
536
+					if ($envLangLabels) {
537 537
 						$proplabel = $envLangLabels[$this->getEnvLang()];
538 538
                     } else {
539
-						if($defaultPropLabel) {
539
+						if ($defaultPropLabel) {
540 540
 							$proplabel = $defaultPropLabel[''];
541 541
 						}
542 542
 					}
@@ -549,12 +549,12 @@  discard block
 block discarded – undo
549 549
                 }
550 550
 
551 551
                 // also look up superprops in the default graph if not found in current vocabulary
552
-                if(!$is_well_known && (!$superprops || empty($superprops))) {
552
+                if (!$is_well_known && (!$superprops || empty($superprops))) {
553 553
                     $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri);
554 554
                 }
555 555
 
556 556
                 // we're reading only one super property, even if there are multiple ones
557
-                $superprop = ($superprops)?$superprops[0]:null;
557
+                $superprop = ($superprops) ? $superprops[0] : null;
558 558
                 if ($superprop) {
559 559
                     $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop;
560 560
                 }
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
                 }
568 568
 
569 569
                 // searching for subproperties of literals too
570
-                if($superprops) {
570
+                if ($superprops) {
571 571
                     foreach ($superprops as $subi) {
572 572
                         $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi;
573 573
                         $duplicates[$suburi] = $prop;
@@ -729,14 +729,14 @@  discard block
 block discarded – undo
729 729
 
730 730
             // making a human readable string from the timestamps
731 731
             if ($created != '') {
732
-                $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short', $this->getEnvLang()));
732
+                $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short', $this->getEnvLang()));
733 733
             }
734 734
 
735 735
             if ($modified != '') {
736 736
                 if ($created != '') {
737
-                    $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang()));
737
+                    $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang()));
738 738
                 } else {
739
-                    $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang()));
739
+                    $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short', $this->getEnvLang()));
740 740
                 }
741 741
 
742 742
             }
@@ -744,12 +744,12 @@  discard block
 block discarded – undo
744 744
             trigger_error($e->getMessage(), E_USER_WARNING);
745 745
             $ret = '';
746 746
             if ($this->resource->get('dc:modified')) {
747
-                $modified = (string) $this->resource->get('dc:modified');
748
-                $ret = gettext('skosmos:modified') . ' ' . $modified;
747
+                $modified = (string)$this->resource->get('dc:modified');
748
+                $ret = gettext('skosmos:modified').' '.$modified;
749 749
             }
750 750
             if ($this->resource->get('dc:created')) {
751
-                $created .= (string) $this->resource->get('dc:created');
752
-                $ret .= ' ' . gettext('skosmos:created') . ' ' . $created;
751
+                $created .= (string)$this->resource->get('dc:created');
752
+                $ret .= ' '.gettext('skosmos:created').' '.$created;
753 753
             }
754 754
         }
755 755
         return $ret;
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                     $groups[$collLabel] = array($group);
822 822
 
823 823
                     $res = $collection;
824
-                    while($super = $this->graph->resourcesMatching('skos:member', $res)) {
824
+                    while ($super = $this->graph->resourcesMatching('skos:member', $res)) {
825 825
                         foreach ($super as $res) {
826 826
                             $superprop = new ConceptPropertyValue($this->model, $this->vocab, $res, 'skosmos:memberOfSuper', $this->clang);
827 827
                             array_unshift($groups[$collLabel], $superprop);
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 
867 867
         foreach ($labels as $lit) {
868 868
             // filtering away subsets of the current language eg. en vs en-GB
869
-            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) {
869
+            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) {
870 870
                 $langCode = $lit->getLang() ? $lit->getLang() : '';
871 871
                 $ret[$langCode][$key][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop);
872 872
             }
@@ -958,10 +958,10 @@  discard block
 block discarded – undo
958 958
             }
959 959
             else if ($context[$vocabPrefix] !== $vocabUriSpace) {
960 960
                 $i = 2;
961
-                while (isset($context[$vocabPrefix . $i]) && $context[$vocabPrefix . $i] !== $vocabUriSpace) {
961
+                while (isset($context[$vocabPrefix.$i]) && $context[$vocabPrefix.$i] !== $vocabUriSpace) {
962 962
                     $i += 1;
963 963
                 }
964
-                $context[$vocabPrefix . $i] = $vocabUriSpace;
964
+                $context[$vocabPrefix.$i] = $vocabUriSpace;
965 965
             }
966 966
         }
967 967
         $compactJsonLD = \ML\JsonLD\JsonLD::compact($this->graph->serialise('jsonld'), json_encode($context));
Please login to merge, or discard this patch.
model/VocabularyConfig.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
     "skos:related", "skos:historyNote", "skosmos:memberOf",
29 29
     "skosmos:memberOfArray");
30 30
 
31
-    public function __construct($resource, $globalPlugins=array())
31
+    public function __construct($resource, $globalPlugins = array())
32 32
     {
33 33
         $this->resource = $resource;
34 34
         $this->globalPlugins = $globalPlugins;
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
                 $paramValue = $paramLiteral->getValue();
118 118
                 $paramLang = $paramLiteral->getLang();
119 119
                 if ($paramLang) {
120
-                    $paramName .= '_' . $paramLang;
120
+                    $paramName .= '_'.$paramLang;
121 121
                 }
122 122
                 $this->pluginParameters[$pluginName][$paramName] = $paramValue;
123 123
             }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
         $langs = $this->getLanguages();
184 184
         $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric
185 185
         if (sizeof($langs) > 1) {
186
-            trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING);
186
+            trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING);
187 187
         }
188 188
 
189 189
         return $deflang;
Please login to merge, or discard this patch.
Braces   +16 added lines, -9 removed lines patch added patch discarded remove patch
@@ -52,8 +52,7 @@  discard block
 block discarded – undo
52 52
             foreach ($vocabularyPlugins as $plugin) {
53 53
                 if ($plugin instanceof EasyRdf\Literal) {
54 54
                     $pluginArray[] = $plugin->getValue();
55
-                }
56
-                else {
55
+                } else {
57 56
                     $pluginArray[] = $plugin->getLiteral('skosmos:usePlugin')->getValue();
58 57
                 }
59 58
             }
@@ -202,8 +201,9 @@  discard block
 block discarded – undo
202 201
     public function getShortName()
203 202
     {
204 203
         $shortname = $this->getLiteral('skosmos:shortName');
205
-        if ($shortname)
206
-          return $shortname;
204
+        if ($shortname) {
205
+                  return $shortname;
206
+        }
207 207
 
208 208
         // if no shortname exists fall back to the id
209 209
         return $this->getId();
@@ -353,10 +353,12 @@  discard block
 block discarded – undo
353 353
         $ret = array();
354 354
         foreach ($resources as $res) {
355 355
             $prop = $res->getURI();
356
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
356
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
357
+              // shortening property labels if possible
357 358
             {
358 359
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
359 360
             }
361
+            }
360 362
 
361 363
             $ret[] = $prop;
362 364
         }
@@ -373,10 +375,12 @@  discard block
 block discarded – undo
373 375
         $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty");
374 376
         foreach ($resources as $res) {
375 377
             $prop = $res->getURI();
376
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
378
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
379
+              // shortening property labels if possible
377 380
             {
378 381
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
379 382
             }
383
+            }
380 384
 
381 385
             if ($prop === $property) {
382 386
                 return true;
@@ -514,11 +518,12 @@  discard block
 block discarded – undo
514 518
     public function getId()
515 519
     {
516 520
         $uriparts = explode("#", $this->resource->getURI());
517
-        if (count($uriparts) != 1)
518
-        // hash namespace
521
+        if (count($uriparts) != 1) {
522
+                // hash namespace
519 523
         {
520 524
             return $uriparts[1];
521 525
         }
526
+        }
522 527
 
523 528
         // slash namespace
524 529
         $uriparts = explode("/", $this->resource->getURI());
@@ -546,10 +551,12 @@  discard block
 block discarded – undo
546 551
         $ret = array();
547 552
         foreach ($resources as $res) {
548 553
             $prop = $res->getURI();
549
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible
554
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
555
+              // prefixing if possible
550 556
             {
551 557
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
552 558
             }
559
+            }
553 560
 
554 561
             $ret[] = $prop;
555 562
         }
Please login to merge, or discard this patch.