Skip to content

Commit

Permalink
feat: add all report messages and essentials property methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielfs7 authored Oct 27, 2021
2 parents f3e91fd + d8bfc68 commit c2526f5
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/report/class.Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ public function getMessage(): string
return $this->message;
}

public function getAllMessages(): string
{
$messages = [$this->getMessage()];

foreach ($this->children as $child) {
$messages[] = $child->getAllMessages();
}

return implode(', ', $messages);
}

/**
* Update message of the report
*
Expand Down
22 changes: 22 additions & 0 deletions core/kernel/classes/class.Property.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,17 @@ public function getDomain()
return $returnValue;
}

public function getRelatedClass(): ?core_kernel_classes_Class
{
try {
$class = $this->getDomain()->get(0);

return $class instanceof core_kernel_classes_Class ? $class : null;
} catch (common_Exception $exception) {
return null;
}
}

/**
* Short description of method setDomain
*
Expand Down Expand Up @@ -227,6 +238,17 @@ public function setRange(core_kernel_classes_Class $class)
return (bool) $returnValue;
}

public function getAlias(): ?string
{
$container = $this->getOnePropertyValue($this->getProperty(GenerisRdf::PROPERTY_ALIAS));

if ($container instanceof core_kernel_classes_Literal) {
return $container->__toString();
}

return null;
}

public function getDependsOnPropertyCollection(): DependsOnPropertyCollection
{
if (!isset($this->dependsOnPropertyCollection)) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/ReportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,16 @@ public function testCreateWithInterpolation(): void
self::assertSame('my data test', $unSerialized->getMessage());
self::assertSame('my data test', $unSerialized->translateMessage());
}

public function testGetAllMessages(): void
{
$report = Report::createInfo('1')
->add(
Report::createSuccess('2')
->add(Report::createWarning('3')
)
);

self::assertEquals('1, 2, 3', $report->getAllMessages());
}
}

0 comments on commit c2526f5

Please sign in to comment.