Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions src/Report/Xml/Facade.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,26 +198,31 @@ private function processUnit(ProcessedClassType|ProcessedTraitType $unit, Report
}

foreach ($unit->methods as $method) {
$methodObject = $unitObject->addMethod($method->methodName);
$methodObject->setSignature($method->signature);
$methodObject->setLines((string) $method->startLine, (string) $method->endLine);
$methodObject->setCrap($method->crap);
$methodObject->setTotals(
$unitObject->addMethod(
$method->methodName,
$method->signature,
(string) $method->startLine,
(string) $method->endLine,
(string) $method->executableLines,
(string) $method->executedLines,
(string) $method->coverage,
$method->crap,
);
}
}

private function processFunction(ProcessedFunctionType $function, Report $report): void
{
$functionObject = $report->functionObject($function->functionName);

$functionObject->setSignature($function->signature);
$functionObject->setLines((string) $function->startLine);
$functionObject->setCrap($function->crap);
$functionObject->setTotals((string) $function->executableLines, (string) $function->executedLines, (string) $function->coverage);
$report->functionObject(
$function->functionName,
$function->signature,
(string) $function->startLine,
null,
(string) $function->executableLines,
(string) $function->executedLines,
(string) $function->coverage,
$function->crap,
);
}

/**
Expand Down
37 changes: 14 additions & 23 deletions src/Report/Xml/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,41 +18,32 @@
{
private DOMElement $contextNode;

public function __construct(DOMElement $context, string $name)
{
public function __construct(
DOMElement $context,
string $name,
string $signature,
string $start,
?string $end,
string $executable,
string $executed,
string $coverage,
string $crap
) {
$this->contextNode = $context;

$this->setName($name);
}

public function setSignature(string $signature): void
{
$this->contextNode->setAttribute('name', $name);
$this->contextNode->setAttribute('signature', $signature);
}

public function setLines(string $start, ?string $end = null): void
{
$this->contextNode->setAttribute('start', $start);

if ($end !== null) {
$this->contextNode->setAttribute('end', $end);
}
}

public function setTotals(string $executable, string $executed, string $coverage): void
{
$this->contextNode->setAttribute('crap', $crap);

$this->contextNode->setAttribute('executable', $executable);
$this->contextNode->setAttribute('executed', $executed);
$this->contextNode->setAttribute('coverage', $coverage);
}

public function setCrap(string $crap): void
{
$this->contextNode->setAttribute('crap', $crap);
}

private function setName(string $name): void
{
$this->contextNode->setAttribute('name', $name);
}
}
24 changes: 21 additions & 3 deletions src/Report/Xml/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,16 @@ public function asDom(): DOMDocument
return $this->dom();
}

public function functionObject(string $name): Method
{
public function functionObject(
string $name,
string $signature,
string $start,
?string $end,
string $executable,
string $executed,
string $coverage,
string $crap
): void {
$node = $this->contextNode()->appendChild(
$this->dom()->createElementNS(
Facade::XML_NAMESPACE,
Expand All @@ -56,7 +64,17 @@ public function functionObject(string $name): Method

assert($node instanceof DOMElement);

return new Method($node, $name);
new Method(
$node,
$name,
$signature,
$start,
$end,
$executable,
$executed,
$coverage,
$crap,
);
}

public function classObject(
Expand Down
24 changes: 21 additions & 3 deletions src/Report/Xml/Unit.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ public function __construct(
$node->setAttribute('name', $namespace);
}

public function addMethod(string $name): Method
{
public function addMethod(
string $name,
string $signature,
string $start,
?string $end,
string $executable,
string $executed,
string $coverage,
string $crap
): void {
$node = $this->contextNode->appendChild(
$this->contextNode->ownerDocument->createElementNS(
Facade::XML_NAMESPACE,
Expand All @@ -58,6 +66,16 @@ public function addMethod(string $name): Method

assert($node instanceof DOMElement);

return new Method($node, $name);
new Method(
$node,
$name,
$signature,
$start,
$end,
$executable,
$executed,
$coverage,
$crap,
);
}
}