Added getLabel() helper function

This commit is contained in:
2026-06-15 09:04:16 +00:00
parent 3c958dc5df
commit 58df9cb476
3 changed files with 17 additions and 0 deletions

View File

@@ -166,4 +166,11 @@ class CloudObject {
return $this->getString(Constants::PROPERTY_REVISION); return $this->getString(Constants::PROPERTY_REVISION);
} }
/**
* Get the rdfs:label of the object.
*/
public function getLabel() : ?string {
return $this->getString(Constants::RDFS_LABEL);
}
} }

View File

@@ -9,5 +9,6 @@ namespace CloudObjects\SDK;
class Constants { class Constants {
const PROPERTY_REVISION = 'coid://cloudobjects.io/isAtRevision'; const PROPERTY_REVISION = 'coid://cloudobjects.io/isAtRevision';
const RDFS_LABEL = 'http://www.w3.org/2000/01/rdf-schema#label';
} }

View File

@@ -126,6 +126,15 @@ class NodeReaderMockTest extends \PHPUnit\Framework\TestCase {
$this->assertEquals('coid://cloudobjects.io/Public', $object->getNode('co:isVisibleTo')->getId()); $this->assertEquals('coid://cloudobjects.io/Public', $object->getNode('co:isVisibleTo')->getId());
} }
public function testConstants() {
$coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock();
$object = $this->retriever->getCloudObject($coid);
$this->assertEquals('6-fbea0c90b2c5e5300e4039ed99be9b2d', $object->getRevision());
$this->assertEquals('CloudObjects', $object->getLabel());
}
public function testGetAllValuesString1() { public function testGetAllValuesString1() {
$coid = new IRI('coid://cloudobjects.io'); $coid = new IRI('coid://cloudobjects.io');
$this->useRootResourceMock(); $this->useRootResourceMock();