Passed
Pull Request — master (#1201)
by
unknown
03:22
created

VocabularyConfig::setPluginParameters()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 12
nc 4
nop 1
dl 0
loc 17
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * VocabularyConfig provides access to the vocabulary configuration defined in config.ttl.
5
 */
6
class VocabularyConfig extends BaseConfig
7
{
8
    private $pluginRegister;
9
    private $pluginParameters = array();
10
    private $languageOrderCache = array();
11
12
    const DEFAULT_PROPERTY_ORDER = array("rdf:type", "dc:isReplacedBy",
13
    "skos:definition", "skos:broader", "isothes:broaderGeneric",
14
    "isothes:broaderPartitive", "isothes:broaderInstantial",
15
    "skos:narrower", "isothes:narrowerGeneric", "isothes:narrowerPartitive",
16
    "isothes:narrowerInstantial", "skos:related", "skos:altLabel",
17
    "skos:note", "skos:scopeNote", "skos:historyNote", "rdfs:comment",
18
    "dc11:source", "dc:source", "skosmos:memberOf", "skosmos:memberOfArray");
19
20
    const ISO25964_PROPERTY_ORDER = array("rdf:type", "dc:isReplacedBy",
21
    // ISO 25964 allows placing all text fields (inc. SN and DEF) together
22
    // so we will do that, except for HN, which is clearly administrative
23
    "skos:note", "skos:scopeNote", "skos:definition", "rdfs:comment",
24
    "dc11:source", "dc:source", "skos:altLabel", "skos:broader",
25
    "isothes:broaderGeneric", "isothes:broaderPartitive",
26
    "isothes:broaderInstantial", "skos:narrower", "isothes:narrowerGeneric",
27
    "isothes:narrowerPartitive", "isothes:narrowerInstantial",
28
    "skos:related", "skos:historyNote", "skosmos:memberOf",
29
    "skosmos:memberOfArray");
30
31
    public function __construct($resource, $globalPlugins=array())
32
    {
33
        $this->resource = $resource;
34
        $this->globalPlugins = $globalPlugins;
0 ignored issues
show
Bug Best Practice introduced by
The property globalPlugins does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        $this->setParametrizedPlugins();
36
        $pluginArray = $this->getPluginArray();
37
        $this->pluginRegister = new PluginRegister($pluginArray);
38
    }
39
40
    /**
41
     * Get an ordered array of plugin names with order configured in skosmos:vocabularyPlugins
42
     * @return array|null of plugin names
43
     */
44
    public function getPluginArray() {
45
46
        $pluginArray = array();
47
48
        $vocabularyPlugins = $this->resource->getResource('skosmos:vocabularyPlugins');
49
        if ($vocabularyPlugins) {
0 ignored issues
show
introduced by
$vocabularyPlugins is of type EasyRdf\Resource, thus it always evaluated to true.
Loading history...
50
            // $vocabularyPlugins has all resources
51
            foreach ($vocabularyPlugins as $plugin) {
52
                if ($plugin instanceof EasyRdf\Literal) {
53
                    $pluginName = $plugin->getValue();
54
                    array_push($pluginArray, $pluginName);
55
                }
56
                else {
57
                    array_push($pluginArray, $plugin->getLiteral('skosmos:usePlugin')->getValue());
58
                }
59
            }
60
        }
61
        $pluginArray = array_merge($pluginArray, $this->globalPlugins);
62
63
        $plugins = $this->resource->allLiterals('skosmos:usePlugin');
64
        if ($plugins) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $plugins of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
65
            foreach ($plugins as $pluginlit) {
66
                $pluginName = $pluginlit->getValue();
67
                array_push($pluginArray, $pluginName);
68
            }
69
        }
70
71
        $pluginArray = array_values(array_unique(array_merge($pluginArray, array_keys($this->pluginParameters))));
72
73
        return $pluginArray;
74
75
    }
76
77
    /**
78
     * Sets array of parameterized plugins
79
     * @param Easyrdf\Resource $pluginResource
80
     */
81
    private function setParametrizedPlugins() {
82
83
        $this->pluginParameters = array();
84
85
        $vocabularyPlugins = $this->resource->getResource('skosmos:vocabularyPlugins');
86
        if ($vocabularyPlugins) {
0 ignored issues
show
introduced by
$vocabularyPlugins is of type EasyRdf\Resource, thus it always evaluated to true.
Loading history...
87
            // $vocabularyPlugins has all resources
88
            foreach ($vocabularyPlugins as $plugin) {
89
                if (!$plugin instanceof EasyRdf\Literal) {
90
                    $this->setPluginParameters($plugin);
91
                }
92
            }
93
        }
94
        $pluginResources = $this->resource->allResources('skosmos:useParamPlugin');
95
        if ($pluginResources) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $pluginResources of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
96
            foreach ($pluginResources as $pluginResource) {
97
                $this->setPluginParameters($pluginResource);
98
            }
99
        }
100
    }
101
102
    /**
103
     * Updates array of parameterized plugins adding parameter values
104
     * @param Easyrdf\Resource $pluginResource
105
     */
106
    private function setPluginParameters(Easyrdf\Resource $pluginResource) : void
107
    {
108
        $pluginName = $pluginResource->getLiteral('skosmos:usePlugin')->getValue();
109
        $this->pluginParameters[$pluginName] = array();
110
111
        $pluginParams = $pluginResource->allResources('skosmos:parameters');
112
        foreach ($pluginParams as $parameter) {
113
114
            $paramLiterals = $parameter->allLiterals('schema:value');
115
            foreach ($paramLiterals as $paramLiteral) {
116
                $paramName = $parameter->getLiteral('schema:propertyID')->getValue();
117
                $paramValue = $paramLiteral->getValue();
118
                $paramLang = $paramLiteral->getLang();
119
                if ($paramLang) {
120
                    $paramName .= '_' . $paramLang;
121
                }
122
                $this->pluginParameters[$pluginName][$paramName] = $paramValue;
123
            }
124
        }
125
    }
126
127
    /**
128
     * Get the SPARQL endpoint URL for this vocabulary
129
     *
130
     * @return string|null endpoint URL, or null if not set
131
     */
132
    public function getSparqlEndpoint()
133
    {
134
        $endpoint = $this->resource->get('void:sparqlEndpoint');
135
        if ($endpoint) {
136
            return $endpoint->getUri();
137
        }
138
        return null;
139
    }
140
141
    /**
142
     * Get the SPARQL graph URI for this vocabulary
143
     *
144
     * @return string|null graph URI, or null if not set
145
     */
146
    public function getSparqlGraph()
147
    {
148
        $graph = $this->resource->get('skosmos:sparqlGraph');
149
        if ($graph) {
150
            $graph = $graph->getUri();
151
        }
152
153
        return $graph;
154
    }
155
156
    /**
157
     * Get the SPARQL dialect for this vocabulary
158
     *
159
     * @return string|null dialect name
160
     */
161
    public function getSparqlDialect()
162
    {
163
        $dialect = $this->resource->get('skosmos:sparqlDialect');
164
        if ($dialect) {
165
            $dialect = $dialect->getValue();
166
        }
167
168
        return $dialect;
169
    }
170
171
    /**
172
     * Get the default language of this vocabulary
173
     * @return string default language, e.g. 'en'
174
     */
175
176
    public function getDefaultLanguage()
177
    {
178
        $deflang = $this->resource->getLiteral('skosmos:defaultLanguage');
179
        if ($deflang) {
0 ignored issues
show
introduced by
$deflang is of type EasyRdf\Literal, thus it always evaluated to true.
Loading history...
180
            return $deflang->getValue();
181
        }
182
183
        $langs = $this->getLanguages();
184
        $deflang = reset($langs); // picking the first one from the list with reset since the keys are not numeric
185
        if (sizeof($langs) > 1) {
186
            trigger_error("Default language for vocabulary '" . $this->getShortName() . "' unknown, choosing '$deflang'.", E_USER_WARNING);
187
        }
188
189
        return $deflang;
190
    }
191
192
    /**
193
     * Whether the alphabetical index is small enough to be shown all at once.
194
     * @return boolean true if all concepts can be shown at once.
195
     */
196
    public function getAlphabeticalFull()
197
    {
198
        return $this->getBoolean('skosmos:fullAlphabeticalIndex');
199
    }
200
201
    /**
202
     * Returns a short name for a vocabulary if configured. If that has not been set
203
     * using vocabId as a fallback.
204
     * @return string
205
     */
206
    public function getShortName()
207
    {
208
        $shortname = $this->getLiteral('skosmos:shortName');
209
        if ($shortname)
210
          return $shortname;
211
212
        // if no shortname exists fall back to the id
213
        return $this->getId();
214
    }
215
216
    /**
217
     * Get the vocabulary feedback e-mail address and return it.
218
     *
219
     * @return string e-mail address or null if not defined.
220
     */
221
    public function getFeedbackRecipient()
222
    {
223
        $email = $this->resource->get('skosmos:feedbackRecipient');
224
        return isset($email) ? $email->getValue() : null;
225
    }
226
227
    /**
228
     * Returns the human readable vocabulary title.
229
     * @return string the title of the vocabulary
230
     */
231
    public function getTitle($lang = null)
232
    {
233
        return $this->getLiteral('dc:title', false, $lang);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $default of BaseConfig::getLiteral(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

233
        return $this->getLiteral('dc:title', /** @scrutinizer ignore-type */ false, $lang);
Loading history...
234
    }
235
236
    /**
237
     * Returns a boolean value set in the config.ttl config.
238
     * @return boolean
239
     */
240
    public function sortByNotation()
241
    {
242
        return $this->getBoolean('skosmos:sortByNotation');
243
    }
244
245
    /**
246
     * Returns a boolean value set in the config.ttl config.
247
     * @return boolean
248
     */
249
    public function showChangeList()
250
    {
251
        return $this->getBoolean('skosmos:showChangeList');
252
    }
253
254
    /**
255
     * get the URLs from which the vocabulary data can be downloaded
256
     * @return array Array with MIME type as key, URL as value
257
     */
258
    public function getDataURLs()
259
    {
260
        $ret = array();
261
        $urls = $this->resource->allResources("void:dataDump");
262
        foreach ($urls as $url) {
263
            // first try dc:format and dc11:format
264
            $mimetypelit = $url->getLiteral('dc:format');
265
            if ($mimetypelit === null) {
266
                $mimetypelit = $url->getLiteral('dc11:format');
267
            }
268
269
            if ($mimetypelit !== null) {
270
                $mimetype = $mimetypelit->getValue();
271
            } else {
272
                $format = EasyRdf\Format::guessFormat(null, $url->getURI());
273
                if ($format === null) {
274
                    trigger_error("Could not guess format for <$url>.", E_USER_WARNING);
275
                    continue;
276
                }
277
                $mimetypes = array_keys($format->getMimeTypes());
278
                $mimetype = $mimetypes[0];
279
            }
280
281
            $langLit = $url->getLiteral('dc:language');
282
283
            if ($langLit != null) {
284
                //when the mimetype has language variants
285
                $dataUrlLang = $langLit->getValue();
286
287
                if (!isset($ret[$mimetype])) {
288
                  $arr = array();
289
                } else {
290
                  $arr = $ret[$mimetype];
291
                }
292
                $arr[$dataUrlLang] = $url->getURI();
293
                $ret[$mimetype] = $arr;
294
            } else {
295
                $ret[$mimetype] = $url->getURI();
296
            }
297
        }
298
        return $ret;
299
    }
300
301
    /**
302
     * Returns the main Concept Scheme URI of that Vocabulary,
303
     * or null if not set.
304
     * @return string concept scheme URI or null
305
     */
306
307
    public function getMainConceptSchemeURI()
308
    {
309
        $val = $this->resource->getResource("skosmos:mainConceptScheme");
310
        if ($val) {
0 ignored issues
show
introduced by
$val is of type EasyRdf\Resource, thus it always evaluated to true.
Loading history...
311
            return $val->getURI();
312
        }
313
314
        return null;
315
    }
316
317
    /**
318
     * Returns the class URI used for concept groups in this vocabulary,
319
     * or null if not set.
320
     * @return string group class URI or null
321
     */
322
323
    public function getGroupClassURI()
324
    {
325
        $val = $this->resource->getResource("skosmos:groupClass");
326
        if ($val) {
0 ignored issues
show
introduced by
$val is of type EasyRdf\Resource, thus it always evaluated to true.
Loading history...
327
            return $val->getURI();
328
        }
329
330
        return null;
331
    }
332
333
    /**
334
     * Returns the class URI used for thesaurus arrays in this vocabulary,
335
     * or null if not set.
336
     * @return string array class URI or null
337
     */
338
339
    public function getArrayClassURI()
340
    {
341
        $val = $this->resource->getResource("skosmos:arrayClass");
342
        if ($val) {
0 ignored issues
show
introduced by
$val is of type EasyRdf\Resource, thus it always evaluated to true.
Loading history...
343
            return $val->getURI();
344
        }
345
346
        return null;
347
    }
348
349
    /**
350
     * Returns custom properties displayed on the search page if configured.
351
     * @return array array class URI or null
352
     */
353
354
    public function getAdditionalSearchProperties()
355
    {
356
        $resources = $this->resource->allResources("skosmos:showPropertyInSearch");
357
        $ret = array();
358
        foreach ($resources as $res) {
359
            $prop = $res->getURI();
360
            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
361
            {
362
                $prop = EasyRdf\RdfNamespace::shorten($prop);
363
            }
364
365
            $ret[] = $prop;
366
        }
367
        return $ret;
368
    }
369
370
    /**
371
     * Queries whether the property should be shown with all the label language variations.
372
     * @param string $property
373
     * @return boolean
374
     */
375
    public function hasMultiLingualProperty($property)
376
    {
377
        $resources = $this->resource->allResources("skosmos:hasMultiLingualProperty");
378
        foreach ($resources as $res) {
379
            $prop = $res->getURI();
380
            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // shortening property labels if possible
381
            {
382
                $prop = EasyRdf\RdfNamespace::shorten($prop);
383
            }
384
385
            if ($prop === $property) {
386
                return true;
387
            }
388
389
        }
390
        return false;
391
    }
392
393
    /**
394
     * Returns a boolean value set in the config.ttl config.
395
     * @return boolean
396
     */
397
    public function getShowHierarchy()
398
    {
399
        return $this->getBoolean('skosmos:showTopConcepts');
400
    }
401
402
    /**
403
     * Returns a boolean value set in the config.ttl config.
404
     * @return boolean
405
     */
406
    public function showConceptSchemesInHierarchy()
407
    {
408
        return $this->getBoolean('skosmos:conceptSchemesInHierarchy');
409
    }
410
411
    /**
412
     * Returns a boolean value set in the config.ttl config.
413
     * @return boolean defaults to true if fetching hasn't been explicitly denied.
414
     */
415
    public function getExternalResourcesLoading()
416
    {
417
        return $this->getBoolean('skosmos:loadExternalResources', true);
418
    }
419
420
    /**
421
     * Returns a boolean value set in the config.ttl config.
422
     * @return boolean
423
     */
424
    public function getShowLangCodes()
425
    {
426
        return $this->getBoolean('skosmos:explicitLanguageTags');
427
    }
428
429
    /**
430
     * Returns a boolean value set in the config.ttl config.
431
     * @return boolean
432
     */
433
    public function searchByNotation()
434
    {
435
        return $this->getBoolean('skosmos:searchByNotation');
436
    }
437
438
    /**
439
     * Returns skosmos:marcSourcecode value set in config.ttl.
440
     * @return string marcsource name
441
     */
442
    public function getMarcSourceCode($lang = null)
443
    {
444
        return $this->getLiteral('skosmos:marcSourceCode', false, $lang);
0 ignored issues
show
Bug introduced by
false of type false is incompatible with the type string expected by parameter $default of BaseConfig::getLiteral(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

444
        return $this->getLiteral('skosmos:marcSourceCode', /** @scrutinizer ignore-type */ false, $lang);
Loading history...
445
    }
446
447
    /**
448
     * Returns a boolean value set in the config.ttl config.
449
     * @return array array of concept class URIs (can be empty)
450
     */
451
    public function getIndexClasses()
452
    {
453
        return $this->getResources("skosmos:indexShowClass");
454
    }
455
456
    /**
457
     * Returns skosmos:externalProperty values set in the config.ttl config.
458
     * @return array array of external property URIs (can be empty)
459
     */
460
    public function getExtProperties()
461
    {
462
        return $this->getResources("skosmos:externalProperty");
463
    }
464
465
    /**
466
     * Get the languages supported by this vocabulary
467
     * @return array languages supported by this vocabulary (as language tag strings)
468
     */
469
    public function getLanguages()
470
    {
471
        $langs = $this->resource->allLiterals('skosmos:language');
472
        $ret = array();
473
        foreach ($langs as $lang) {
474
            $langlit = Punic\Language::getName($lang->getValue(), $this->getEnvLang());
475
            $ret[$langlit] = $lang->getValue();
476
        }
477
        ksort($ret);
478
479
        return $ret;
480
    }
481
482
    /**
483
     * Returns the plugin parameters
484
     * @return string plugin parameters or null
485
     */
486
    public function getPluginParameters() {
487
        return $this->pluginParameters;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->pluginParameters returns the type array which is incompatible with the documented return type string.
Loading history...
488
    }
489
490
    /**
491
     * Returns the plugin parameters
492
     * @return string plugin parameters or null
493
     */
494
    public function getEncodedPluginParameters() {
495
        return json_encode($this->pluginParameters, true);
0 ignored issues
show
Bug introduced by
true of type true is incompatible with the type integer expected by parameter $flags of json_encode(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

495
        return json_encode($this->pluginParameters, /** @scrutinizer ignore-type */ true);
Loading history...
496
    }
497
498
    /**
499
     * Returns the vocabulary default sidebar view.
500
     * @return string name of the view
501
     */
502
    public function getDefaultSidebarView()
503
    {
504
        $defview = $this->resource->getLiteral('skosmos:defaultSidebarView');
505
        if ($defview) {
0 ignored issues
show
introduced by
$defview is of type EasyRdf\Literal, thus it always evaluated to true.
Loading history...
506
            $value = $defview->getValue();
507
            if ($value === 'groups' || $value === 'hierarchy') {
508
                return $value;
509
            }
510
511
        }
512
        if ($this->showAlphabeticalIndex() === false) {
513
            if ($this->getShowHierarchy()) {
514
                return 'hierarchy';
515
            } else if ($this->getGroupClassURI()) {
516
                return 'groups';
517
            }
518
        }
519
        return 'alphabetical'; // if not defined displaying the alphabetical index
520
    }
521
522
    /**
523
     * Extracts the vocabulary id string from the baseuri of the vocabulary.
524
     * @return string identifier eg. 'mesh'.
525
     */
526
    public function getId()
527
    {
528
        $uriparts = explode("#", $this->resource->getURI());
529
        if (count($uriparts) != 1)
530
        // hash namespace
531
        {
532
            return $uriparts[1];
533
        }
534
535
        // slash namespace
536
        $uriparts = explode("/", $this->resource->getURI());
537
538
        return $uriparts[count($uriparts) - 1];
539
    }
540
541
    public function getShowStatistics() {
542
        return $this->getBoolean('skosmos:showStatistics', true);
543
    }
544
545
    public function getPluginRegister()
546
    {
547
        return $this->pluginRegister;
548
    }
549
550
    /**
551
     * Returns the property/properties used for visualizing concept hierarchies.
552
     * @return array array class URI or null
553
     */
554
555
    public function getHierarchyProperty()
556
    {
557
        $resources = $this->resource->allResources("skosmos:hierarchyProperty");
558
        $ret = array();
559
        foreach ($resources as $res) {
560
            $prop = $res->getURI();
561
            if (EasyRdf\RdfNamespace::shorten($prop) !== null) // prefixing if possible
562
            {
563
                $prop = EasyRdf\RdfNamespace::shorten($prop);
564
            }
565
566
            $ret[] = $prop;
567
        }
568
        return empty($ret) ? array('skos:broader') : $ret;
569
    }
570
571
    /**
572
     * Returns a boolean value set in the config.ttl config.
573
     * @return boolean
574
     */
575
    public function showNotation()
576
    {
577
        return $this->getBoolean('skosmos:showNotation', true);
578
    }
579
580
    /**
581
     * Returns a boolean value set in the config.ttl config.
582
     * @return boolean
583
     */
584
    public function showAlphabeticalIndex()
585
    {
586
        return $this->getBoolean('skosmos:showAlphabeticalIndex', true);
587
    }
588
589
    /**
590
     * Returns the alphabetical list qualifier in this vocabulary,
591
     * or null if not set.
592
     * @return EasyRdf\Resource|null alphabetical list qualifier resource or null
593
     */
594
    public function getAlphabeticalListQualifier()
595
    {
596
        return $this->resource->getResource('skosmos:alphabeticalListQualifier');
597
    }
598
599
    /**
600
     * Returns a boolean value set in the config.ttl config.
601
     * @return boolean
602
     */
603
    public function getShowDeprecated()
604
    {
605
        return $this->getBoolean('skosmos:showDeprecated', false);
606
    }
607
608
    /**
609
     * Returns the vocabulary dc:type value(s) with their labels and uris, if set in the vocabulary configuration.
610
     * @return array of objects or an empty array
611
     */
612
    public function getTypes($lang = null)
613
    {
614
        $resources = $this->resource->allResources("dc:type");
615
        $ret = array();
616
        foreach ($resources as $res) {
617
            $prop = $res->getURI();
618
            $label = $res->label($lang) ? $res->label($lang) : $res->label($this->getDefaultLanguage());
619
            $ret[] = array('uri' => $prop, 'prefLabel' =>  $label->getValue());
620
        }
621
        return $ret;
622
    }
623
624
    /**
625
     * Returns an array of fallback languages that is ordered by priority and
626
     * defined in the vocabulary configuration as a collection.
627
     * Additionally, the chosen content language is inserted with the highest priority
628
     * and the vocab default language is inserted with the lowest priority.
629
     * @param string $clang
630
     * @return array of language code strings
631
     */
632
    public function getLanguageOrder($clang)
633
    {
634
        if (array_key_exists($clang, $this->languageOrderCache)) {
635
            return $this->languageOrderCache[$clang];
636
        }
637
        $ret = array($clang);
638
        $fallbacks = !empty($this->resource->get('skosmos:fallbackLanguages')) ? $this->resource->get('skosmos:fallbackLanguages') : array();
639
        foreach ($fallbacks as $lang) {
640
            if (!in_array($lang, $ret)) {
641
                $ret[] = (string)$lang; // Literal to string conversion
642
            }
643
        }
644
        if (!in_array($this->getDefaultLanguage(), $ret)) {
645
            $ret[] = (string)$this->getDefaultLanguage();
646
        }
647
        foreach ($this->getLanguages() as $lang) {
648
            if (!in_array($lang, $ret)) {
649
                $ret[] = $lang;
650
            }
651
        }
652
        // store in cache so this doesn't have to be computed again
653
        $this->languageOrderCache[$clang] = $ret;
654
        return $ret;
655
    }
656
657
    /**
658
     * @return boolean
659
     */
660
    public function isUseModifiedDate()
661
    {
662
        return $this->getBoolean('skosmos:useModifiedDate', false);
663
    }
664
665
    /**
666
     * @return array
667
     */
668
    public function getPropertyOrder()
669
    {
670
        $order = $this->getResource()->getResource('skosmos:propertyOrder');
671
        if ($order === null) {
672
            return self::DEFAULT_PROPERTY_ORDER;
673
        }
674
675
        $short = EasyRdf\RdfNamespace::shorten($order);
676
        if ($short == 'skosmos:iso25964PropertyOrder') {
677
            return self::ISO25964_PROPERTY_ORDER;
678
        } elseif ($short == 'skosmos:defaultPropertyOrder') {
679
            return self::DEFAULT_PROPERTY_ORDER;
680
        }
681
        
682
        // check for custom order definition
683
        $orderList = $order->getResource('rdf:value');
684
        if ($orderList !== null && $orderList instanceof EasyRdf\Collection) {
685
            $ret = array();
686
            foreach ($orderList as $prop) {
687
                $short = $prop->shorten();
0 ignored issues
show
Bug introduced by
The method shorten() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

687
                /** @scrutinizer ignore-call */ 
688
                $short = $prop->shorten();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
688
                $ret[] = ($short !== null) ? $short : $prop->getURI();
689
            }
690
            return $ret;
691
        }
692
        
693
        trigger_error("Property order for vocabulary '{$this->getShortName()}' unknown, using default order", E_USER_WARNING);
694
        return self::DEFAULT_PROPERTY_ORDER;
695
    }
696
}
697