Completed
Pull Request — master (#899)
by Dan Michael O.
01:48
created
model/BaseConfig.php 3 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
      * @param string $default default value
43 43
      * @param string $lang preferred language for the literal
44 44
      */
45
-    protected function getLiteral($property, $default=null, $lang=null)
45
+    protected function getLiteral($property, $default = null, $lang = null)
46 46
     {
47 47
         if (!isset($lang)) {;
48 48
             $lang = $this->getEnvLang();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,8 +55,9 @@
 block discarded – undo
55 55
 
56 56
         // not found with selected language, try any language
57 57
         $literal = $this->getResource()->getLiteral($property);
58
-        if ($literal)
59
-          return $literal->getValue();
58
+        if ($literal) {
59
+                  return $literal->getValue();
60
+        }
60 61
 
61 62
         return $default;
62 63
     }
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,11 +7,11 @@
 block discarded – undo
7 7
 abstract class BaseConfig extends DataObject
8 8
 {
9 9
 
10
-	/**
11
-     * Returns a boolean value based on a literal value from the config.ttl configuration.
12
-     * @param string $property the property to query
13
-     * @param boolean $default the default value if the value is not set in configuration
14
-     */
10
+  /**
11
+   * Returns a boolean value based on a literal value from the config.ttl configuration.
12
+   * @param string $property the property to query
13
+   * @param boolean $default the default value if the value is not set in configuration
14
+   */
15 15
     protected function getBoolean($property, $default = false)
16 16
     {
17 17
         $val = $this->getResource()->getLiteral($property);
Please login to merge, or discard this patch.
model/VocabularyConfig.php 3 patches
Braces   +15 added lines, -7 removed lines patch added patch discarded remove patch
@@ -58,8 +58,9 @@  discard block
 block discarded – undo
58 58
     public function getShortName()
59 59
     {
60 60
         $shortname = $this->getLiteral('skosmos:shortName');
61
-        if ($shortname)
62
-          return $shortname;
61
+        if ($shortname) {
62
+                  return $shortname;
63
+        }
63 64
 
64 65
         // if no shortname exists fall back to the id
65 66
         return $this->getId();
@@ -194,10 +195,12 @@  discard block
 block discarded – undo
194 195
         $ret = array();
195 196
         foreach ($resources as $res) {
196 197
             $prop = $res->getURI();
197
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
198
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
199
+              // shortening property labels if possible
198 200
             {
199 201
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
200 202
             }
203
+            }
201 204
 
202 205
             $ret[] = $prop;
203 206
         }
@@ -214,10 +217,12 @@  discard block
 block discarded – undo
214 217
         $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty");
215 218
         foreach ($resources as $res) {
216 219
             $prop = $res->getURI();
217
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
220
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
221
+              // shortening property labels if possible
218 222
             {
219 223
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
220 224
             }
225
+            }
221 226
 
222 227
             if ($prop === $property) {
223 228
                 return true;
@@ -329,11 +334,12 @@  discard block
 block discarded – undo
329 334
     public function getId()
330 335
     {
331 336
         $uriparts = explode("#", $this->resource->getURI());
332
-        if (count($uriparts) != 1)
333
-        // hash namespace
337
+        if (count($uriparts) != 1) {
338
+                // hash namespace
334 339
         {
335 340
             return $uriparts[1];
336 341
         }
342
+        }
337 343
 
338 344
         // slash namespace
339 345
         $uriparts = explode("/", $this->resource->getURI());
@@ -361,10 +367,12 @@  discard block
 block discarded – undo
361 367
         $ret = array();
362 368
         foreach ($resources as $res) {
363 369
             $prop = $res->getURI();
364
-            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible
370
+            if (EasyRdf\RdfNamespace::shorten($prop) !== null) {
371
+              // prefixing if possible
365 372
             {
366 373
                 $prop = EasyRdf\RdfNamespace::shorten($prop);
367 374
             }
375
+            }
368 376
 
369 377
             $ret[] = $prop;
370 378
         }
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -266,6 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
     /**
268 268
      * Returns skosmos:marcSourcecode value set in config.ttl.
269
+     * @param string $lang
269 270
      * @return string marcsource name
270 271
      */
271 272
     public function getMarcSourceCode($lang = null)
@@ -275,7 +276,7 @@  discard block
 block discarded – undo
275 276
 
276 277
     /**
277 278
      * Returns a boolean value set in the config.ttl config.
278
-     * @return array array of concept class URIs (can be empty)
279
+     * @return string[] array of concept class URIs (can be empty)
279 280
      */
280 281
     public function getIndexClasses()
281 282
     {
@@ -284,7 +285,7 @@  discard block
 block discarded – undo
284 285
 
285 286
     /**
286 287
      * Returns skosmos:externalProperty values set in the config.ttl config.
287
-     * @return array array of external property URIs (can be empty)
288
+     * @return string[] array of external property URIs (can be empty)
288 289
      */
289 290
     public function getExtProperties()
290 291
     {
@@ -410,6 +411,7 @@  discard block
 block discarded – undo
410 411
 
411 412
     /**
412 413
      * Returns the vocabulary dc:type value(s) with their labels and uris, if set in the vocabulary configuration.
414
+     * @param string $lang
413 415
      * @return array of objects or an empty array
414 416
      */
415 417
     public function getTypes($lang = null)
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
     private $plugins;
9 9
     private $languageOrderCache = array();
10 10
 
11
-    public function __construct($resource, $globalPlugins=array())
11
+    public function __construct($resource, $globalPlugins = array())
12 12
     {
13 13
         $this->resource = $resource;
14 14
         $plugins = $this->resource->allLiterals('skosmos:usePlugin');
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
         $langs = $this->getLanguages();
37 37
         $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric
38 38
         if (sizeof($langs) > 1) {
39
-            trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING);
39
+            trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING);
40 40
         }
41 41
 
42 42
         return $deflang;
Please login to merge, or discard this patch.
migrate-config.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@
 block discarded – undo
84 84
     foreach (explode(' ', GLOBAL_PLUGINS) as $pluginName) {
85 85
         $globalPluginsArray[] = "\"$pluginName\"";
86 86
     }
87
-    $globalPlugins = " " . implode(', ', $globalPluginsArray) . " ";
87
+    $globalPlugins = " ".implode(', ', $globalPluginsArray)." ";
88 88
 }
89 89
 
90 90
 # print the prefixes
Please login to merge, or discard this patch.
controller/EntityController.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@
 block discarded – undo
30 30
             $url = $baseurl . "$vocid/";
31 31
         } else {
32 32
 
33
-   	        if ($localname !== $uri && $localname === urlencode($localname)) {
34
-   	        // the URI can be shortened
33
+              if ($localname !== $uri && $localname === urlencode($localname)) {
34
+              // the URI can be shortened
35 35
             $url = $baseurl . "$vocid/page/$localname";
36 36
             } else {
37 37
                 // must use full URI
38
-   	            $query = http_build_query(array('uri'=>$uri));
38
+                  $query = http_build_query(array('uri'=>$uri));
39 39
                 $url = $baseurl . "$vocid/page/?" . $query;
40
-	        }
40
+          }
41 41
         }
42 42
         $this->redirect303($url);
43 43
     }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
         $baseurl = $this->getBaseHref();
17 17
         $vocid = $vocab->getId();
18 18
         $query = http_build_query(array('uri'=>$uri, 'format'=>$targetFormat));
19
-        $url = $baseurl . "rest/v1/$vocid/data?$query";
19
+        $url = $baseurl."rest/v1/$vocid/data?$query";
20 20
         $this->redirect303($url);
21 21
     }
22 22
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
         $localname = $vocab->getLocalName($uri);
28 28
 
29 29
         if (!$localname) {
30
-            $url = $baseurl . "$vocid/";
30
+            $url = $baseurl."$vocid/";
31 31
         } else {
32 32
 
33 33
    	        if ($localname !== $uri && $localname === urlencode($localname)) {
34 34
    	        // the URI can be shortened
35
-            $url = $baseurl . "$vocid/page/$localname";
35
+            $url = $baseurl."$vocid/page/$localname";
36 36
             } else {
37 37
                 // must use full URI
38 38
    	            $query = http_build_query(array('uri'=>$uri));
39
-                $url = $baseurl . "$vocid/page/?" . $query;
39
+                $url = $baseurl."$vocid/page/?".$query;
40 40
 	        }
41 41
         }
42 42
         $this->redirect303($url);
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
             // guess vocabulary based on URI
58 58
             $vocab = $this->model->guessVocabularyFromURI($request->getUri());
59 59
             if ($vocab === null) {
60
-                return $this->returnError('404', 'Not Found', 'Unrecognized URI ' . $request->getUri());
60
+                return $this->returnError('404', 'Not Found', 'Unrecognized URI '.$request->getUri());
61 61
             }
62 62
             $request->setVocab($vocab->getId());
63 63
         }
Please login to merge, or discard this patch.
model/ConceptMappingPropertyValue.php 2 patches
Doc Comments   +2 added lines patch added patch discarded remove patch
@@ -169,6 +169,8 @@
 block discarded – undo
169 169
 
170 170
     /**
171 171
      * Return the mapping as a JSKOS-compatible array.
172
+     * @param string $lang
173
+     * @param string $hrefLink
172 174
      * @return array
173 175
      */
174 176
     public function asJskos($queryExVocabs = true, $lang = null, $hrefLink = null)
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         $label = $this->getLabel();
38 38
         $notation = $this->getNotation();
39
-        return ltrim($notation . ' ') . $label;
39
+        return ltrim($notation.' ').$label;
40 40
     }
41 41
 
42 42
     public function getType()
@@ -187,42 +187,42 @@  discard block
 block discarded – undo
187 187
             'from' => [
188 188
                 'memberSet' => [
189 189
                     [
190
-                        'uri' => (string) $this->source->getUri(),
190
+                        'uri' => (string)$this->source->getUri(),
191 191
                     ]
192 192
                 ]
193 193
             ],
194 194
             'to' => [
195 195
                 'memberSet' => [
196 196
                     [
197
-                        'uri' => (string) $this->getUri()
197
+                        'uri' => (string)$this->getUri()
198 198
                     ]
199 199
                 ]
200 200
             ],
201 201
             // EXTRA
202
-            'description' => gettext($this->type . "_help"), // pop-up text
202
+            'description' => gettext($this->type."_help"), // pop-up text
203 203
             'hrefLink' => $hrefLink, // link to resource as displayed in the UI
204 204
             'lang' => $propertyLang, // TBD: could it be part of the prefLabel?
205
-            'vocabName' => (string) $this->getVocabName(), // vocabulary as displayed in the UI
205
+            'vocabName' => (string)$this->getVocabName(), // vocabulary as displayed in the UI
206 206
             'typeLabel' => gettext($this->type), // a text used in the UI instead of, for example, skos:closeMatch
207 207
         ];
208 208
 
209 209
         $fromScheme = $this->vocab->getDefaultConceptScheme();
210 210
         if (isset($fromScheme)) {
211 211
             $ret['fromScheme'] = [
212
-                'uri' => (string) $fromScheme,
212
+                'uri' => (string)$fromScheme,
213 213
             ];
214 214
         }
215 215
 
216 216
         $exvocab = $this->getExvocab();
217 217
         if (isset($exvocab)) {
218 218
             $ret['toScheme'] = [
219
-                'uri' => (string) $exvocab->getDefaultConceptScheme(),
219
+                'uri' => (string)$exvocab->getDefaultConceptScheme(),
220 220
             ];
221 221
         }
222 222
 
223 223
         $notation = $this->getNotation();
224 224
         if (isset($notation)) {
225
-            $ret['to']['memberSet'][0]['notation'] = (string) $notation;
225
+            $ret['to']['memberSet'][0]['notation'] = (string)$notation;
226 226
         }
227 227
 
228 228
         $label = $this->getLabel($lang, $queryExVocabs);
Please login to merge, or discard this patch.
model/ConceptPropertyValue.php 1 patch
Spacing   +4 added lines, -4 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 = ltrim($this->getNotation() . ' ') . $label;
27
+            $label = ltrim($this->getNotation().' ').$label;
28 28
         }
29 29
 
30 30
         return $label;
@@ -47,9 +47,9 @@  discard block
 block discarded – undo
47 47
                 }
48 48
                 // We need to check all the labels in case one of them matches a subtag of the current language
49 49
                 if ($this->resource->allLiterals('skos:prefLabel')) {
50
-                    foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
50
+                    foreach ($this->resource->allLiterals('skos:prefLabel') as $label) {
51 51
                         // the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
52
-                        if ($label !== null && strpos($label->getLang(), $fallback . '-') === 0) {
52
+                        if ($label !== null && strpos($label->getLang(), $fallback.'-') === 0) {
53 53
                             return EasyRdf\Literal::create($label, $fallback);
54 54
                         }
55 55
                     }
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
     public function getReifiedPropertyValues() {
142 142
         $ret = array();
143 143
         $props = $this->resource->propertyUris();
144
-        foreach($props as $prop) {
144
+        foreach ($props as $prop) {
145 145
             $prop = (EasyRdf\RdfNamespace::shorten($prop) !== null) ? EasyRdf\RdfNamespace::shorten($prop) : $prop;
146 146
             foreach ($this->resource->allLiterals($prop) as $val) {
147 147
                 if ($prop !== 'rdf:value') { // shown elsewhere
Please login to merge, or discard this patch.
model/ConceptProperty.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
      * @param string $prop property type eg. 'rdf:type'.
23 23
      * @param string $label
24 24
      */
25
-    public function __construct($prop, $label, $super=null, $sort_by_notation=false)
25
+    public function __construct($prop, $label, $super = null, $sort_by_notation = false)
26 26
     {
27 27
         $this->prop = $prop;
28 28
         $this->label = $label;
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function getDescription()
63 63
     {
64
-        $helpprop = $this->prop . "_help";
64
+        $helpprop = $this->prop."_help";
65 65
 
66 66
         return gettext($helpprop); // can't use string constant, it'd be picked up by xgettext
67 67
     }
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
     public function addValue($value)
82 82
     {
83
-        $this->values[ltrim($value->getNotation() . ' ') . $value->getLabel() . rtrim(' ' . $value->getUri())] = $value;
83
+        $this->values[ltrim($value->getNotation().' ').$value->getLabel().rtrim(' '.$value->getUri())] = $value;
84 84
         $this->is_sorted = false;
85 85
     }
86 86
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     {
89 89
         if (!empty($this->values)) {
90 90
             uksort($this->values, function($a, $b) {
91
-                return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a),strtolower($b));
91
+                return $this->sort_by_notation ? strnatcasecmp($a, $b) : strcoll(strtolower($a), strtolower($b));
92 92
             });
93 93
         }
94 94
         $this->is_sorted = true;
Please login to merge, or discard this patch.
controller/Controller.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -142,18 +142,18 @@  discard block
 block discarded – undo
142 142
         $localname = $vocab->getLocalName($uri);
143 143
         if ($localname !== $uri && $localname === urlencode($localname)) {
144 144
             // check that the prefix stripping worked, and there are no problematic chars in localname
145
-            $paramstr = count($params) > 0 ? '?' . http_build_query($params) : '';
145
+            $paramstr = count($params) > 0 ? '?'.http_build_query($params) : '';
146 146
             if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) {
147
-                return "$vocid/$lang/$type/$localname" . $paramstr;
147
+                return "$vocid/$lang/$type/$localname".$paramstr;
148 148
             }
149 149
 
150
-            return "$vocid/$lang/$localname" . $paramstr;
150
+            return "$vocid/$lang/$localname".$paramstr;
151 151
         }
152 152
 
153 153
         // case 2: URI outside vocabulary namespace, or has problematic chars
154 154
         // pass the full URI as parameter instead
155 155
         $params['uri'] = $uri;
156
-        return "$vocid/$lang/$type/?" . http_build_query($params);
156
+        return "$vocid/$lang/$type/?".http_build_query($params);
157 157
     }
158 158
 
159 159
     /**
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
     {
188 188
         if ($modifiedDate) {
189 189
             $ifModifiedSince = $this->getIfModifiedSince();
190
-            $this->sendHeader("Last-Modified: " . $modifiedDate->format('Y-m-d H:i:s'));
190
+            $this->sendHeader("Last-Modified: ".$modifiedDate->format('Y-m-d H:i:s'));
191 191
             if (!is_null($ifModifiedSince) && $ifModifiedSince >= $modifiedDate) {
192 192
                 $this->sendHeader("HTTP/1.0 304 Not Modified");
193 193
                 return true;
Please login to merge, or discard this patch.
model/resolver/LOCResource.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
             $opts = array('http' => array('method'=>'HEAD',
14 14
                                           'user_agent' => 'Skosmos',
15 15
                                           'timeout' => $timeout));
16
-            $context  = stream_context_create($opts);
16
+            $context = stream_context_create($opts);
17 17
             $fd = fopen($this->uri, 'rb', false, $context);
18 18
             $headers = stream_get_meta_data($fd)['wrapper_data'];
19 19
             foreach ($headers as $header) {
Please login to merge, or discard this patch.