Completed
Push — master ( cfbaac...db0318 )
by Henri
09:36
created
model/Concept.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -50,6 +50,7 @@  discard block
 block discarded – undo
50 50
      * @param Vocabulary $vocab
51 51
      * @param EasyRdf\Resource $resource
52 52
      * @param EasyRdf\Graph $graph
53
+     * @param string|null $clang
53 54
      */
54 55
     public function __construct($model, $vocab, $resource, $graph, $clang)
55 56
     {
@@ -526,6 +527,7 @@  discard block
 block discarded – undo
526 527
 
527 528
     /**
528 529
      * Gets the groups/arrays the concept belongs to.
530
+     * @param boolean $includeArrays
529 531
      */
530 532
     public function getReverseResources($includeArrays) {
531 533
         $groups = array();
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 
122 122
         // 3. label in a subtag of the current language
123 123
         // We need to check all the labels in case one of them matches a subtag of the current language
124
-        foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
124
+        foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
125 125
             // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
126
-            if ($label !== null && strpos($label->getLang(), $lang . '-') === 0) {
126
+            if ($label !== null && strpos($label->getLang(), $lang.'-') === 0) {
127 127
                 return EasyRdf\Literal::create($label, $lang);
128 128
             }
129 129
         }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         // 4. label in any language, including literal with empty language tag
132 132
         $label = $this->resource->label();
133 133
         if ($label !== null) {
134
-            return $label->getLang() ? $label->getValue() . " (" . $label->getLang() . ")" : $label->getValue();
134
+            return $label->getLang() ? $label->getValue()." (".$label->getLang().")" : $label->getValue();
135 135
         }
136 136
 
137 137
         // empty
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 
141 141
     public function hasXlLabel($prop = 'prefLabel')
142 142
     {
143
-        if ($this->resource->hasProperty('skosxl:' . $prop)) {
143
+        if ($this->resource->hasProperty('skosxl:'.$prop)) {
144 144
             return true;
145 145
         }
146 146
         return false;
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
     public function getXlLabel()
150 150
     {
151 151
         $labels = $this->resource->allResources('skosxl:prefLabel');
152
-        foreach($labels as $labres) {
152
+        foreach ($labels as $labres) {
153 153
             $label = $labres->getLiteral('skosxl:literalForm');
154 154
             if ($label->getLang() == $this->clang) {
155 155
                 return new LabelSkosXL($this->model, $labres);
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
                 // if not found in current vocabulary, look up in the default graph to be able
361 361
                 // to read an ontology loaded in a separate graph
362 362
                 // note that this imply that the property has an rdf:type declared for the query to work
363
-                if(!$proplabel) {
363
+                if (!$proplabel) {
364 364
                     $envLangLabels = $this->model->getDefaultSparql()->queryLabel($longUri, $this->getEnvLang());
365
-                    $proplabel = ($envLangLabels)?$envLangLabels[$this->getEnvLang()]:$this->model->getDefaultSparql()->queryLabel($longUri, '')[''];
365
+                    $proplabel = ($envLangLabels) ? $envLangLabels[$this->getEnvLang()] : $this->model->getDefaultSparql()->queryLabel($longUri, '')[''];
366 366
                 }                
367 367
                 
368 368
                 // look for superproperties in the current graph
@@ -372,12 +372,12 @@  discard block
 block discarded – undo
372 372
                 }
373 373
                 
374 374
                 // also look up superprops in the default graph if not found in current vocabulary
375
-                if(!$superprops || empty($superprops)) {
375
+                if (!$superprops || empty($superprops)) {
376 376
                     $superprops = $this->model->getDefaultSparql()->querySuperProperties($longUri);
377 377
                 }
378 378
                 
379 379
                 // we're reading only one super property, even if there are multiple ones
380
-                $superprop = ($superprops)?$superprops[0]:null;                
380
+                $superprop = ($superprops) ? $superprops[0] : null;                
381 381
                 if ($superprop) {
382 382
                     $superprop = EasyRdf\RdfNamespace::shorten($superprop) ? EasyRdf\RdfNamespace::shorten($superprop) : $superprop;
383 383
                 }
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
                 }
390 390
 
391 391
                 // searching for subproperties of literals too
392
-                if($superprops) {
392
+                if ($superprops) {
393 393
                     foreach ($superprops as $subi) {
394 394
                         $suburi = EasyRdf\RdfNamespace::shorten($subi) ? EasyRdf\RdfNamespace::shorten($subi) : $subi;
395 395
                         $duplicates[$suburi] = $prop;
@@ -509,14 +509,14 @@  discard block
 block discarded – undo
509 509
 
510 510
             // making a human readable string from the timestamps
511 511
             if ($created != '') {
512
-                $ret = gettext('skosmos:created') . ' ' . (Punic\Calendar::formatDate($created, 'short'));
512
+                $ret = gettext('skosmos:created').' '.(Punic\Calendar::formatDate($created, 'short'));
513 513
             }
514 514
 
515 515
             if ($modified != '') {
516 516
                 if ($created != '') {
517
-                    $ret .= ', ' . gettext('skosmos:modified') . ' ' . (Punic\Calendar::formatDate($modified, 'short'));
517
+                    $ret .= ', '.gettext('skosmos:modified').' '.(Punic\Calendar::formatDate($modified, 'short'));
518 518
                 } else {
519
-                    $ret .= ' ' . ucfirst(gettext('skosmos:modified')) . ' ' . (Punic\Calendar::formatDate($modified, 'short'));
519
+                    $ret .= ' '.ucfirst(gettext('skosmos:modified')).' '.(Punic\Calendar::formatDate($modified, 'short'));
520 520
                 }
521 521
 
522 522
             }
@@ -524,12 +524,12 @@  discard block
 block discarded – undo
524 524
             trigger_error($e->getMessage(), E_USER_WARNING);
525 525
             $ret = '';
526 526
             if ($this->resource->get('dc:modified')) {
527
-                $modified = (string) $this->resource->get('dc:modified');
528
-                $ret = gettext('skosmos:modified') . ' ' . $modified; 
527
+                $modified = (string)$this->resource->get('dc:modified');
528
+                $ret = gettext('skosmos:modified').' '.$modified; 
529 529
             }
530 530
             if ($this->resource->get('dc:created')) {
531
-                $created .= (string) $this->resource->get('dc:created');
532
-                $ret .= ' ' . gettext('skosmos:created') . ' ' . $created; 
531
+                $created .= (string)$this->resource->get('dc:created');
532
+                $ret .= ' '.gettext('skosmos:created').' '.$created; 
533 533
             }
534 534
         }
535 535
         return $ret;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
         $ret = array();
640 640
         foreach ($labels as $lit) {
641 641
             // filtering away subsets of the current language eg. en vs en-GB
642
-            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang() . '-') !== 0) {
642
+            if ($lit->getLang() != $this->clang && strpos($lit->getLang(), $this->getEnvLang().'-') !== 0) {
643 643
                 $prop = in_array($lit, $prefLabels) ? 'skos:prefLabel' : 'skos:altLabel';
644 644
                 $ret[$this->literalLanguageToString($lit)][] = new ConceptPropertyValueLiteral($this->model, $this->vocab, $this->resource, $lit, $prop);
645 645
             }
Please login to merge, or discard this patch.
model/ConceptPropertyValue.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $label = is_string($this->getLabel()) ? $this->getLabel() : $this->getLabel()->getValue();
26 26
         if ($this->vocab->getConfig()->sortByNotation()) {
27
-            $label = $this->getNotation() . $label;
27
+            $label = $this->getNotation().$label;
28 28
         }
29 29
 
30 30
         return $label;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
     public function getReifiedPropertyValues() {
121 121
         $ret = array();
122 122
         $props = $this->resource->propertyUris();
123
-        foreach($props as $prop) {
123
+        foreach ($props as $prop) {
124 124
             $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop;
125 125
             foreach ($this->resource->allLiterals($prop) as $val) {
126 126
                 if ($prop !== 'rdf:value' && $this->resource->get($prop)) { // shown elsewhere
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -12,6 +12,9 @@  discard block
 block discarded – undo
12 12
     /** content language */
13 13
     private $clang;
14 14
 
15
+    /**
16
+     * @param Model $model
17
+     */
15 18
     public function __construct($model, $vocab, $resource, $prop, $clang = '')
16 19
     {
17 20
         parent::__construct($model, $vocab, $resource);
@@ -76,6 +79,9 @@  discard block
 block discarded – undo
76 79
         return $this->vocab->getTitle();
77 80
     }
78 81
 
82
+    /**
83
+     * @param ConceptPropertyValue $member
84
+     */
79 85
     public function addSubMember($member, $lang = '')
80 86
     {
81 87
         $label = $member->getLabel($lang) ? $member->getLabel($lang) : $member->getLabel();
Please login to merge, or discard this patch.
model/sparql/JenaTextSparql.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         // 1. Ensure characters with special meaning in Lucene are escaped
41 41
         $lucenemap = array();
42 42
         foreach (str_split(self::LUCENE_ESCAPE_CHARS) as $char) {
43
-            $lucenemap[$char] = '\\' . $char; // escape with a backslash
43
+            $lucenemap[$char] = '\\'.$char; // escape with a backslash
44 44
         }
45 45
         $term = strtr($term, $lucenemap);
46 46
 
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      * @return string sparql order by clause
83 83
      */
84 84
     private function formatOrderBy($expression, $lang) {
85
-        if(!$this->model->getConfig()->getCollationEnabled()) {
85
+        if (!$this->model->getConfig()->getCollationEnabled()) {
86 86
             return $expression;
87 87
         }
88 88
         $orderby = sprintf('arq:collation(\'%2$s\', %1$s)', $expression, $lang);
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
 
115 115
         # make text query clause
116 116
         $lcletter = mb_strtolower($letter, 'UTF-8'); // convert to lower case, UTF-8 safe
117
-        $textcondPref = $this->createTextQueryCondition($letter . '*', 'skos:prefLabel', $lang);
118
-        $textcondAlt = $this->createTextQueryCondition($letter . '*', 'skos:altLabel', $lang);
117
+        $textcondPref = $this->createTextQueryCondition($letter.'*', 'skos:prefLabel', $lang);
118
+        $textcondAlt = $this->createTextQueryCondition($letter.'*', 'skos:altLabel', $lang);
119 119
         $orderbyclause = $this->formatOrderBy("LCASE(?match)", $lang);
120 120
 
121
-        $filterDeprecated="";
122
-        if(!$showDeprecated){
123
-            $filterDeprecated="FILTER NOT EXISTS { ?s owl:deprecated true }";
121
+        $filterDeprecated = "";
122
+        if (!$showDeprecated) {
123
+            $filterDeprecated = "FILTER NOT EXISTS { ?s owl:deprecated true }";
124 124
         }
125 125
         
126 126
         $query = <<<EOQ
Please login to merge, or discard this patch.
model/Model.php 2 patches
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
     private function initializeVocabularies()
65 65
     {
66 66
         if (!file_exists($this->getConfig()->getVocabularyConfigFile())) {
67
-            throw new Exception($this->getConfig()->getVocabularyConfigFile() . ' is missing, please provide one.');
67
+            throw new Exception($this->getConfig()->getVocabularyConfigFile().' is missing, please provide one.');
68 68
         }
69 69
 
70 70
         try {
71 71
             // use APC user cache to store parsed vocabularies.ttl configuration
72 72
             if ($this->cache->isAvailable()) {
73 73
                 // @codeCoverageIgnoreStart
74
-                $key = realpath($this->getConfig()->getVocabularyConfigFile()) . ", " . filemtime($this->getConfig()->getVocabularyConfigFile());
75
-                $nskey = "namespaces of " . $key;
74
+                $key = realpath($this->getConfig()->getVocabularyConfigFile()).", ".filemtime($this->getConfig()->getVocabularyConfigFile());
75
+                $nskey = "namespaces of ".$key;
76 76
                 $this->graph = $this->cache->fetch($key);
77 77
                 $this->namespaces = $this->cache->fetch($nskey);
78 78
                 if ($this->graph === false || $this->namespaces === false) { // was not found in cache
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 $this->parseVocabularies($this->getConfig()->getVocabularyConfigFile());
86 86
             }
87 87
         } catch (Exception $e) {
88
-            echo "Error: " . $e->getMessage();
88
+            echo "Error: ".$e->getMessage();
89 89
         }
90 90
     }
91 91
 
@@ -297,18 +297,18 @@  discard block
 block discarded – undo
297 297
         }
298 298
 
299 299
         $vocabs = $params->getVocabs();
300
-        $showDeprecated=false;
300
+        $showDeprecated = false;
301 301
         if (sizeof($vocabs) === 1) { // search within vocabulary
302 302
             $voc = $vocabs[0];
303 303
             $sparql = $voc->getSparql();
304
-            $showDeprecated=$voc->getConfig()->getShowDeprecated();
304
+            $showDeprecated = $voc->getConfig()->getShowDeprecated();
305 305
         } else { // multi-vocabulary or global search
306 306
             $voc = null;
307 307
             $sparql = $this->getDefaultSparql();
308 308
             // @TODO : in a global search showDeprecated will always be false and cannot be set globally
309 309
         }
310 310
 
311
-        $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params,$showDeprecated);
311
+        $results = $sparql->queryConcepts($vocabs, $params->getAdditionalFields(), $params->getUnique(), $params, $showDeprecated);
312 312
         if ($params->getRest() && $results && $params->getSearchLimit() !== 0) {
313 313
           $results = array_slice($results, $params->getOffset(), $params->getSearchLimit());
314 314
         }
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
     public function getVocabularyCategories()
459 459
     {
460 460
         $cats = $this->graph->allOfType('skos:Concept');
461
-        if(empty($cats)) {
461
+        if (empty($cats)) {
462 462
             return array(new VocabularyCategory($this, null));
463 463
         }
464 464
 
@@ -541,9 +541,9 @@  discard block
 block discarded – undo
541 541
         }
542 542
         
543 543
         // if there are multiple vocabularies and one is the preferred vocabulary, return it
544
-        if($preferredVocabId != null) {
544
+        if ($preferredVocabId != null) {
545 545
             foreach ($vocabs as $vocab) {
546
-                if($vocab->getId() == $preferredVocabId) {
546
+                if ($vocab->getId() == $preferredVocabId) {
547 547
                     return $vocab;
548 548
                 }
549 549
             }
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
         // using apc cache for the resource if available
644 644
         if ($this->cache->isAvailable()) {
645 645
             // @codeCoverageIgnoreStart
646
-            $key = 'fetch: ' . $uri;
646
+            $key = 'fetch: '.$uri;
647 647
             $resource = $this->cache->fetch($key);
648 648
             if ($resource === null || $resource === false) { // was not found in cache, or previous request failed
649 649
                 $resource = $this->fetchResourceFromUri($uri);
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
      */
665 665
     public function getSparqlImplementation($dialect, $endpoint, $graph)
666 666
     {
667
-        $classname = $dialect . "Sparql";
667
+        $classname = $dialect."Sparql";
668 668
 
669 669
         return new $classname($endpoint, $graph, $this);
670 670
     }
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -108,10 +108,12 @@  discard block
 block discarded – undo
108 108
     
109 109
     private function initializeNamespaces() {
110 110
         foreach ($this->namespaces as $prefix => $fullUri) {
111
-            if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined
111
+            if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) {
112
+              // if not already defined
112 113
             {
113 114
                 EasyRdf\RdfNamespace::set($prefix, $fullUri);
114 115
             }
116
+            }
115 117
         }
116 118
     }
117 119
     
@@ -425,10 +427,12 @@  discard block
 block discarded – undo
425 427
                 // register vocabulary ids as RDF namespace prefixes
426 428
                 $prefix = preg_replace('/\W+/', '', $voc->getId()); // strip non-word characters
427 429
                 try {
428
-                    if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) // if not already defined
430
+                    if ($prefix != '' && EasyRdf\RdfNamespace::get($prefix) === null) {
431
+                      // if not already defined
429 432
                     {
430 433
                         EasyRdf\RdfNamespace::set($prefix, $voc->getUriSpace());
431 434
                     }
435
+                    }
432 436
 
433 437
                 } catch (Exception $e) {
434 438
                     // not valid as namespace identifier, ignore
@@ -551,8 +555,9 @@  discard block
 block discarded – undo
551 555
         
552 556
         // no preferred vocabulary, or it was not found, search in which vocabulary the concept has a label
553 557
         foreach ($vocabs as $vocab) {
554
-            if ($vocab->getConceptLabel($uri, null) !== null)
555
-                return $vocab;
558
+            if ($vocab->getConceptLabel($uri, null) !== null) {
559
+                            return $vocab;
560
+            }
556 561
         }
557 562
 
558 563
         // if the URI couldn't be found, fall back to the first vocabulary
Please login to merge, or discard this patch.
model/ConceptPropertyValueLiteral.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -10,6 +10,9 @@
 block discarded – undo
10 10
     /** property type */
11 11
     private $type;
12 12
 
13
+    /**
14
+     * @param EasyRdf\Resource $resource
15
+     */
13 16
     public function __construct($model, $vocab, $resource, $literal, $prop)
14 17
     {
15 18
         parent::__construct($model, $vocab, $resource);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 return Punic\Calendar::formatDate($val, 'short');
50 50
             } catch (Exception $e) {
51 51
                 trigger_error($e->getMessage(), E_USER_WARNING);
52
-                return (string) $this->literal;
52
+                return (string)$this->literal;
53 53
             }
54 54
         }
55 55
         return $this->literal->getValue();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         $resources = $graph->resourcesMatching('skosxl:literalForm', $this->literal);
81 81
         foreach ($resources as $xlres) {
82 82
             foreach ($xlres->properties() as $prop) {
83
-                foreach($graph->allLiterals($xlres, $prop) as $val) {
83
+                foreach ($graph->allLiterals($xlres, $prop) as $val) {
84 84
                     if ($prop !== 'rdf:type') {
85 85
                         $ret[$prop] = $val;
86 86
                     }
Please login to merge, or discard this patch.
model/LabelSkosXL.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -3,6 +3,9 @@
 block discarded – undo
3 3
 class LabelSkosXL extends DataObject
4 4
 {
5 5
 
6
+    /**
7
+     * @param Model $model
8
+     */
6 9
     public function __construct($model, $resource)
7 10
     {
8 11
         parent::__construct($model, $resource);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
     public function getPrefLabel() {
12 12
         $label;
13 13
         $labels = $this->resource->allResources('skosxl:prefLabel');
14
-        foreach($labels as $labres) {
14
+        foreach ($labels as $labres) {
15 15
             $label = $labres->getLiteral('skosxl:literalForm');
16 16
             if ($label->getLang() == $this->clang) {
17 17
                 return $label;
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function getProperties() {
24 24
         $ret = array();
25 25
         $props = $this->resource->properties();
26
-        foreach($props as $prop) {
26
+        foreach ($props as $prop) {
27 27
             if ($prop !== 'skosxl:prefLabel') {
28 28
                 $ret[$prop] = $this->resource->get($prop);
29 29
             }
Please login to merge, or discard this patch.