Skip to content

Commit 5058041

Browse files
staabmsebastianbergmann
authored andcommitted
Report: Reduce dependency on DOM
1 parent bc41506 commit 5058041

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Report/Xml/Report.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
final class Report extends File
2222
{
23+
private readonly string $name;
24+
2325
public function __construct(string $name)
2426
{
2527
$dom = new DOMDocument;
@@ -32,11 +34,14 @@ public function __construct(string $name)
3234

3335
parent::__construct($contextNode);
3436

35-
$this->setName($name);
37+
$this->name = $name;
3638
}
3739

3840
public function asDom(): DOMDocument
3941
{
42+
$this->contextNode()->setAttribute('name', basename($this->name));
43+
$this->contextNode()->setAttribute('path', dirname($this->name));
44+
4045
return $this->dom();
4146
}
4247

@@ -85,12 +90,6 @@ public function source(): Source
8590
return new Source($source);
8691
}
8792

88-
private function setName(string $name): void
89-
{
90-
$this->contextNode()->setAttribute('name', basename($name));
91-
$this->contextNode()->setAttribute('path', dirname($name));
92-
}
93-
9493
private function unitObject(string $tagName, string $name): Unit
9594
{
9695
$node = $this->contextNode()->appendChild(

0 commit comments

Comments
 (0)