1
|
|
|
<?php declare(strict_types = 1); |
2
|
|
|
|
3
|
|
|
namespace JSKOS; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* JSKOS Specification version aligned with. |
7
|
|
|
*/ |
8
|
|
|
const JSKOS_SPECIFICATION = '0.1.4'; |
9
|
|
|
|
10
|
|
|
use InvalidArgumentException; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A JSKOS resource with support of common fields. |
14
|
|
|
* |
15
|
|
|
* @see https://gbv.github.io/jskos/jskos.html#jskos-resources |
16
|
|
|
*/ |
17
|
|
|
abstract class Resource extends DataType |
18
|
|
|
{ |
19
|
|
|
const TYPES = []; |
20
|
|
|
|
21
|
|
|
const FIELDS = [ |
22
|
|
|
'uri' => 'URI', |
23
|
|
|
'type' => ['Listing'], |
24
|
|
|
'created' => 'Date', |
25
|
|
|
'issued' => 'Date', |
26
|
|
|
'modified' => 'Date', |
27
|
|
|
'creator' => ['Set','Concept'], |
28
|
|
|
'contributor' => ['Set','Concept'], |
29
|
|
|
'publisher' => ['Set','Concept'], |
30
|
|
|
'partOf' => ['Set','Concept'], |
31
|
|
|
]; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* URI if the Concept, ConceptScheme, ConceptType, Mapping |
35
|
|
|
* or whatever this resource refers to. |
36
|
|
|
*/ |
37
|
|
|
protected $uri; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Resource types(s). |
41
|
|
|
*/ |
42
|
|
|
protected $type; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Date of creation. |
46
|
|
|
*/ |
47
|
|
|
protected $created; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* Date of protectedation. |
51
|
|
|
*/ |
52
|
|
|
protected $issued; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Date of last modification. |
56
|
|
|
*/ |
57
|
|
|
protected $modified; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Agent primarily responsible for creation of resource. |
61
|
|
|
*/ |
62
|
|
|
protected $creator; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Agent responsible for making contributions to the resource. |
66
|
|
|
*/ |
67
|
|
|
protected $contributor; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Agent responsible for making the resource available. |
71
|
|
|
*/ |
72
|
|
|
protected $publisher; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Resources which this resource is part of. |
76
|
|
|
*/ |
77
|
|
|
protected $partOf; |
78
|
|
|
|
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* Guess subclass from list of type URIs. |
82
|
|
|
*/ |
83
|
|
|
public static function guessClassFromTypes(array $types) |
84
|
|
|
{ |
85
|
|
|
if (count($types)) { |
86
|
|
|
foreach (['ConceptScheme', 'Concordance', 'Mapping', 'Concept'] as $class) { |
87
|
|
|
$class = "JSKOS\\$class"; |
88
|
|
|
foreach ($class::TYPES as $uri) { |
89
|
|
|
if (in_array($uri, $types)) { |
90
|
|
|
return $class; |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|