1 | <?php |
||
51 | class Thing implements ThingInterface |
||
52 | { |
||
53 | /** |
||
54 | * Resource type |
||
55 | * |
||
56 | * @var string |
||
57 | */ |
||
58 | protected $type; |
||
59 | /** |
||
60 | * Resource vocabulary |
||
61 | * |
||
62 | * @var VocabularyInterface |
||
63 | */ |
||
64 | protected $vocabulary; |
||
65 | /** |
||
66 | * Resource ID |
||
67 | * |
||
68 | * @var string|null |
||
69 | */ |
||
70 | protected $resourceId = null; |
||
71 | /** |
||
72 | * Child things |
||
73 | * |
||
74 | * @var ThingInterface[] |
||
75 | */ |
||
76 | protected $children = []; |
||
77 | /** |
||
78 | * Property |
||
79 | * |
||
80 | * @var array[] |
||
81 | */ |
||
82 | protected $properties = []; |
||
83 | |||
84 | /** |
||
85 | * Thing constructor |
||
86 | * |
||
87 | * @param string $type Resource type |
||
88 | * @param VocabularyInterface $vocabulary Vocabulary in use |
||
89 | * @param null|string $resourceId Resource id |
||
90 | */ |
||
91 | 23 | public function __construct($type, VocabularyInterface $vocabulary, $resourceId = null) |
|
105 | |||
106 | /** |
||
107 | * Return the resource type |
||
108 | * |
||
109 | * @return string Resource type |
||
110 | */ |
||
111 | 5 | public function getType() |
|
115 | |||
116 | /** |
||
117 | * Return the vocabulary in use |
||
118 | * |
||
119 | * @return VocabularyInterface Vocabulary |
||
120 | */ |
||
121 | 5 | public function getVocabulary() |
|
125 | |||
126 | /** |
||
127 | * Return the resource ID |
||
128 | * |
||
129 | * @return null|string Resource ID |
||
130 | */ |
||
131 | 6 | public function getResourceId() |
|
135 | |||
136 | /** |
||
137 | * Add a property value |
||
138 | * |
||
139 | * @param PropertyInterface $property Property |
||
140 | * @return Thing Self reference |
||
141 | */ |
||
142 | 5 | public function addProperty(PropertyInterface $property) |
|
156 | |||
157 | /** |
||
158 | * Return all properties |
||
159 | * |
||
160 | * @return array[] Properties |
||
161 | */ |
||
162 | 6 | public function getProperties() |
|
166 | |||
167 | /** |
||
168 | * Return the values of a single property |
||
169 | * |
||
170 | * @param string $name Property name |
||
171 | * @param VocabularyInterface $vocabulary Vocabulary |
||
172 | * @return array Property values |
||
173 | */ |
||
174 | 4 | public function getProperty($name, VocabularyInterface $vocabulary) |
|
189 | |||
190 | /** |
||
191 | * Add a child |
||
192 | * |
||
193 | * @param ThingInterface $child Child |
||
194 | * @return Thing Self reference |
||
195 | */ |
||
196 | 6 | public function addChild(ThingInterface $child) |
|
201 | |||
202 | /** |
||
203 | * Return all children |
||
204 | * |
||
205 | * @return ThingInterface[] Children |
||
206 | */ |
||
207 | 7 | public function getChildren() |
|
211 | } |
||
212 |