Skip to content

Commit 8ec04ae

Browse files
committed
Remove unnecessary indirection via dom()-method
unifies the access pattern, as some places where already directly working with the property, while others accessed it via dom()
1 parent d8bf935 commit 8ec04ae

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

src/Report/Xml/File.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
class File
2020
{
21-
private readonly DOMDocument $dom;
21+
protected readonly DOMDocument $dom;
2222
private readonly DOMElement $contextNode;
2323

2424
public function __construct(DOMElement $context)
@@ -77,9 +77,4 @@ protected function contextNode(): DOMElement
7777
{
7878
return $this->contextNode;
7979
}
80-
81-
protected function dom(): DOMDocument
82-
{
83-
return $this->dom;
84-
}
8580
}

src/Report/Xml/Node.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919
abstract class Node
2020
{
21-
private readonly DOMDocument $dom;
21+
protected readonly DOMDocument $dom;
2222
private readonly DOMElement $contextNode;
2323

2424
public function __construct(DOMElement $context)
@@ -27,11 +27,6 @@ public function __construct(DOMElement $context)
2727
$this->contextNode = $context;
2828
}
2929

30-
public function dom(): DOMDocument
31-
{
32-
return $this->dom;
33-
}
34-
3530
public function totals(): Totals
3631
{
3732
$totalsContainer = $this->contextNode()->firstChild;
@@ -52,7 +47,7 @@ public function totals(): Totals
5247

5348
public function addDirectory(string $name): Directory
5449
{
55-
$dirNode = $this->dom()->createElementNS(
50+
$dirNode = $this->dom->createElementNS(
5651
Facade::XML_NAMESPACE,
5752
'directory',
5853
);
@@ -65,7 +60,7 @@ public function addDirectory(string $name): Directory
6560

6661
public function addFile(string $name, string $href): File
6762
{
68-
$fileNode = $this->dom()->createElementNS(
63+
$fileNode = $this->dom->createElementNS(
6964
Facade::XML_NAMESPACE,
7065
'file',
7166
);

src/Report/Xml/Project.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public function projectSourceDirectory(): string
4242

4343
public function buildInformation(): BuildInformation
4444
{
45-
$buildNode = $this->dom()->getElementsByTagNameNS(
45+
$buildNode = $this->dom->getElementsByTagNameNS(
4646
Facade::XML_NAMESPACE,
4747
'build',
4848
)->item(0);
4949

5050
if ($buildNode === null) {
51-
$buildNode = $this->dom()->documentElement->appendChild(
52-
$this->dom()->createElementNS(
51+
$buildNode = $this->dom->documentElement->appendChild(
52+
$this->dom->createElementNS(
5353
Facade::XML_NAMESPACE,
5454
'build',
5555
),
@@ -70,7 +70,7 @@ public function tests(): Tests
7070

7171
if ($testsNode === null) {
7272
$testsNode = $this->contextNode()->appendChild(
73-
$this->dom()->createElementNS(
73+
$this->dom->createElementNS(
7474
Facade::XML_NAMESPACE,
7575
'tests',
7676
),
@@ -86,6 +86,6 @@ public function asDom(): DOMDocument
8686
{
8787
$this->contextNode()->setAttribute('source', $this->directory);
8888

89-
return $this->dom();
89+
return $this->dom;
9090
}
9191
}

src/Report/Xml/Report.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function asDom(): DOMDocument
4242
$this->contextNode()->setAttribute('name', basename($this->name));
4343
$this->contextNode()->setAttribute('path', dirname($this->name));
4444

45-
return $this->dom();
45+
return $this->dom;
4646
}
4747

4848
public function functionObject(
@@ -56,7 +56,7 @@ public function functionObject(
5656
string $crap
5757
): void {
5858
$node = $this->contextNode()->appendChild(
59-
$this->dom()->createElementNS(
59+
$this->dom->createElementNS(
6060
Facade::XML_NAMESPACE,
6161
'function',
6262
),
@@ -86,7 +86,7 @@ public function classObject(
8686
float $crap
8787
): Unit {
8888
$node = $this->contextNode()->appendChild(
89-
$this->dom()->createElementNS(
89+
$this->dom->createElementNS(
9090
Facade::XML_NAMESPACE,
9191
'class',
9292
),
@@ -106,7 +106,7 @@ public function traitObject(
106106
float $crap
107107
): Unit {
108108
$node = $this->contextNode()->appendChild(
109-
$this->dom()->createElementNS(
109+
$this->dom->createElementNS(
110110
Facade::XML_NAMESPACE,
111111
'trait',
112112
),
@@ -126,7 +126,7 @@ public function source(): Source
126126

127127
if ($source === null) {
128128
$source = $this->contextNode()->appendChild(
129-
$this->dom()->createElementNS(
129+
$this->dom->createElementNS(
130130
Facade::XML_NAMESPACE,
131131
'source',
132132
),

0 commit comments

Comments
 (0)