Passed
Push — issue1627-initialize-model-glo... ( a66e70 )
by Osma
05:50
created
src/model/Model.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * Initializes the Model object
31 31
      */
32
-    public function __construct(string $config_filename="../../config.ttl")
32
+    public function __construct(string $config_filename = "../../config.ttl")
33 33
     {
34 34
         $this->resolver = new Resolver($this);
35 35
         $this->globalConfig = new GlobalConfig($this, $config_filename);
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
                 $this->translator = new Translator($langcode);
41 41
             }
42 42
             $this->translator->addLoader('po', new PoFileLoader());
43
-            $this->translator->addResource('po', __DIR__.'/../../resource/translations/skosmos_' . $langcode . '.po', $langcode);
43
+            $this->translator->addResource('po', __DIR__.'/../../resource/translations/skosmos_'.$langcode.'.po', $langcode);
44 44
         }
45 45
         $this->initializeLogging();
46 46
     }
@@ -274,11 +274,11 @@  discard block
 block discarded – undo
274 274
         }
275 275
 
276 276
         $vocabs = $params->getVocabs();
277
-        $showDeprecated=false;
277
+        $showDeprecated = false;
278 278
         if (sizeof($vocabs) === 1) { // search within vocabulary
279 279
             $voc = $vocabs[0];
280 280
             $sparql = $voc->getSparql();
281
-            $showDeprecated=$voc->getConfig()->getShowDeprecated();
281
+            $showDeprecated = $voc->getConfig()->getShowDeprecated();
282 282
         } else { // multi-vocabulary or global search
283 283
             $voc = null;
284 284
             $sparql = $this->getDefaultSparql();
@@ -439,7 +439,7 @@  discard block
 block discarded – undo
439 439
     public function getVocabularyCategories()
440 440
     {
441 441
         $cats = $this->globalConfig->getGraph()->allOfType('skos:Concept');
442
-        if(empty($cats)) {
442
+        if (empty($cats)) {
443 443
             return array(new VocabularyCategory($this, null));
444 444
         }
445 445
 
@@ -520,9 +520,9 @@  discard block
 block discarded – undo
520 520
         }
521 521
 
522 522
         // if there are multiple vocabularies and one is the preferred vocabulary, return it
523
-        if($preferredVocabId != null) {
523
+        if ($preferredVocabId != null) {
524 524
             foreach ($vocabs as $vocab) {
525
-                if($vocab->getId() == $preferredVocabId) {
525
+                if ($vocab->getId() == $preferredVocabId) {
526 526
                     try {
527 527
                         // double check that a label exists in the preferred vocabulary
528 528
                         if ($vocab->getConceptLabel($uri, null) !== null) {
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
                         }
534 534
                     } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
535 535
                         if ($this->getConfig()->getLogCaughtExceptions()) {
536
-                            error_log('Caught exception: ' . $e->getMessage());
536
+                            error_log('Caught exception: '.$e->getMessage());
537 537
                         }
538 538
                         break;
539 539
                     }
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
                 }
550 550
             } catch (EasyRdf\Http\Exception | EasyRdf\Exception | Throwable $e) {
551 551
                 if ($this->getConfig()->getLogCaughtExceptions()) {
552
-                    error_log('Caught exception: ' . $e->getMessage());
552
+                    error_log('Caught exception: '.$e->getMessage());
553 553
                 }
554 554
                 break;
555 555
             }
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
         // using apc cache for the resource if available
623 623
         if ($this->globalConfig->getCache()->isAvailable()) {
624 624
             // @codeCoverageIgnoreStart
625
-            $key = 'fetch: ' . $uri;
625
+            $key = 'fetch: '.$uri;
626 626
             $resource = $this->globalConfig->getCache()->fetch($key);
627 627
             if ($resource === null || $resource === false) { // was not found in cache, or previous request failed
628 628
                 $resource = $this->resolver->resolve($uri, $this->getConfig()->getHttpTimeout());
@@ -643,7 +643,7 @@  discard block
 block discarded – undo
643 643
      */
644 644
     public function getSparqlImplementation($dialect, $endpoint, $graph)
645 645
     {
646
-        $classname = $dialect . "Sparql";
646
+        $classname = $dialect."Sparql";
647 647
 
648 648
         return new $classname($endpoint, $graph, $this);
649 649
     }
Please login to merge, or discard this patch.
src/model/VocabularyConfig.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     "skos:related", "skos:historyNote", "skosmos:memberOf",
31 31
     "skosmos:memberOfArray");
32 32
 
33
-    public function __construct(Model $model, $resource, $globalPlugins=array())
33
+    public function __construct(Model $model, $resource, $globalPlugins = array())
34 34
     {
35 35
         parent::__construct($model, $resource);
36 36
         $this->globalPlugins = $globalPlugins;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 $paramValue = $paramLiteral->getValue();
124 124
                 $paramLang = $paramLiteral->getLang();
125 125
                 if ($paramLang) {
126
-                    $paramName .= '_' . $paramLang;
126
+                    $paramName .= '_'.$paramLang;
127 127
                 }
128 128
                 $this->pluginParameters[$pluginName][$paramName] = $paramValue;
129 129
             }
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
         $labelProperty = $override->getResource('skosmos:property');
156 156
         $labelPropUri = $labelProperty->shorten();
157 157
         if (empty($this->labelOverrides[$labelPropUri])) {
158
-            $this->labelOverrides[$labelPropUri]  = array();
158
+            $this->labelOverrides[$labelPropUri] = array();
159 159
         }
160 160
         $newOverrides = array();
161 161
 
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
         $langs = $this->getLanguages();
230 230
         $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric
231 231
         if (sizeof($langs) > 1) {
232
-            trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING);
232
+            trigger_error("Default language for vocabulary '".$this->getShortName()."' unknown, choosing '$deflang'.", E_USER_WARNING);
233 233
         }
234 234
 
235 235
         return $deflang;
Please login to merge, or discard this patch.
src/model/GlobalConfig.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,17 +30,17 @@  discard block
 block discarded – undo
30 30
      */
31 31
     private $configModifiedTime = null;
32 32
 
33
-    public function __construct(Model $model, $config_name='../../config.ttl')
33
+    public function __construct(Model $model, $config_name = '../../config.ttl')
34 34
     {
35 35
         $this->cache = new Cache();
36 36
         try {
37
-            $this->filePath = realpath(dirname(__FILE__) . "/" . $config_name);
37
+            $this->filePath = realpath(dirname(__FILE__)."/".$config_name);
38 38
             if (!file_exists($this->filePath)) {
39 39
                 throw new Exception('config.ttl file is missing, please provide one.');
40 40
             }
41 41
             $resource = $this->initializeConfig();
42 42
         } catch (Exception $e) {
43
-            echo "Error: " . $e->getMessage();
43
+            echo "Error: ".$e->getMessage();
44 44
             return;
45 45
         }
46 46
         parent::__construct($model, $resource);
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             // use APC user cache to store parsed config.ttl configuration
76 76
             if ($this->cache->isAvailable() && !is_null($this->configModifiedTime)) {
77 77
                 // @codeCoverageIgnoreStart
78
-                $key = realpath($this->filePath) . ", " . $this->configModifiedTime;
79
-                $nskey = "namespaces of " . $key;
78
+                $key = realpath($this->filePath).", ".$this->configModifiedTime;
79
+                $nskey = "namespaces of ".$key;
80 80
                 $this->graph = $this->cache->fetch($key);
81 81
                 $this->namespaces = $this->cache->fetch($nskey);
82 82
                 if ($this->graph === false || $this->namespaces === false) { // was not found in cache
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             }
97 97
             return $configResources[0];
98 98
         } catch (Exception $e) {
99
-            echo "Error: " . $e->getMessage();
99
+            echo "Error: ".$e->getMessage();
100 100
         }
101 101
         return null;
102 102
     }
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
     public function getGlobalPlugins()
330 330
     {
331 331
         $globalPlugins = array();
332
-        $globalPluginsResource =  $this->getResource()->getResource("skosmos:globalPlugins");
332
+        $globalPluginsResource = $this->getResource()->getResource("skosmos:globalPlugins");
333 333
         if ($globalPluginsResource) {
334 334
             foreach ($globalPluginsResource as $resource) {
335 335
                 $globalPlugins[] = $resource->getValue();
Please login to merge, or discard this patch.
src/index.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
     }
10 10
     require_once '../vendor/autoload.php';
11 11
 } catch (Exception $e) {
12
-    echo "Error: " . $e->getMessage();
12
+    echo "Error: ".$e->getMessage();
13 13
     return;
14 14
 }
15 15
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
     // if language code missing, redirect to guessed language
27 27
     // in any case, redirect to <lang>/
28 28
     $lang = sizeof($parts) == 2 && $parts[1] !== '' ? $parts[1] : $controller->guessLanguage($request);
29
-    header("Location: " . $lang . "/");
29
+    header("Location: ".$lang."/");
30 30
 } else {
31 31
     if (array_key_exists($parts[1], $model->getConfig()->getLanguages())) { // global pages
32 32
         $request->setLang($parts[1]);
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
         }
57 57
         if (sizeof($parts) == 3) { // language code missing
58 58
             $lang = $controller->guessLanguage($request);
59
-            $newurl = $controller->getBaseHref() . $vocab . "/" . $lang . "/";
60
-            header("Location: " . $newurl);
59
+            $newurl = $controller->getBaseHref().$vocab."/".$lang."/";
60
+            header("Location: ".$newurl);
61 61
         } else {
62 62
             if (array_key_exists($parts[2], $model->getConfig()->getLanguages())) {
63 63
                 $lang = $parts[2];
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
                 }
99 99
             } else { // language code missing, redirect to some language version
100 100
                 $lang = $controller->guessLanguage($request, $vocab);
101
-                $newurl = $controller->getBaseHref() . $vocab . "/" . $lang . "/" . implode('/', array_slice($parts, 2));
101
+                $newurl = $controller->getBaseHref().$vocab."/".$lang."/".implode('/', array_slice($parts, 2));
102 102
                 $qs = $request->getServerConstant('QUERY_STRING');
103 103
                 if ($qs) {
104
-                    $newurl .= "?" . $qs;
104
+                    $newurl .= "?".$qs;
105 105
                 }
106 106
                 header("Location: $newurl");
107 107
             }
Please login to merge, or discard this patch.