Skip to content

Commit 2afc038

Browse files
staabmsebastianbergmann
authored andcommitted
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 f0b16b3 commit 2afc038

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
@@ -19,7 +19,7 @@
1919
*/
2020
class File
2121
{
22-
private readonly DOMDocument $dom;
22+
protected readonly DOMDocument $dom;
2323
private readonly DOMElement $contextNode;
2424
private ?DOMNode $lineCoverage = null;
2525

@@ -71,9 +71,4 @@ protected function contextNode(): DOMElement
7171
{
7272
return $this->contextNode;
7373
}
74-
75-
protected function dom(): DOMDocument
76-
{
77-
return $this->dom;
78-
}
7974
}

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
@@ -48,14 +48,14 @@ public function buildInformation(
4848
string $phpUnitVersion,
4949
string $coverageVersion
5050
): void {
51-
$buildNode = $this->dom()->getElementsByTagNameNS(
51+
$buildNode = $this->dom->getElementsByTagNameNS(
5252
Facade::XML_NAMESPACE,
5353
'build',
5454
)->item(0);
5555

5656
if ($buildNode === null) {
57-
$buildNode = $this->dom()->documentElement->appendChild(
58-
$this->dom()->createElementNS(
57+
$buildNode = $this->dom->documentElement->appendChild(
58+
$this->dom->createElementNS(
5959
Facade::XML_NAMESPACE,
6060
'build',
6161
),
@@ -76,7 +76,7 @@ public function buildInformation(
7676
public function tests(): Tests
7777
{
7878
$testsNode = $this->contextNode()->appendChild(
79-
$this->dom()->createElementNS(
79+
$this->dom->createElementNS(
8080
Facade::XML_NAMESPACE,
8181
'tests',
8282
),
@@ -91,6 +91,6 @@ public function asDom(): DOMDocument
9191
{
9292
$this->contextNode()->setAttribute('source', $this->directory);
9393

94-
return $this->dom();
94+
return $this->dom;
9595
}
9696
}

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
),
@@ -120,7 +120,7 @@ public function traitObject(
120120
public function source(): Source
121121
{
122122
$source = $this->contextNode()->appendChild(
123-
$this->dom()->createElementNS(
123+
$this->dom->createElementNS(
124124
Facade::XML_NAMESPACE,
125125
'source',
126126
),

0 commit comments

Comments
 (0)