Skip to content

Commit 59ff966

Browse files
committed
Extract xml namespace into global constant
1 parent 9a5ff2a commit 59ff966

File tree

10 files changed

+30
-29
lines changed

10 files changed

+30
-29
lines changed

src/Report/Xml/BuildInformation.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ public function setGeneratorVersions(string $phpUnitVersion, string $coverageVer
6262
private function nodeByName(string $name): DOMElement
6363
{
6464
$node = $this->contextNode->getElementsByTagNameNS(
65-
'https://schema.phpunit.de/coverage/1.0',
65+
Facade::XML_NS,
6666
$name,
6767
)->item(0);
6868

6969
if ($node === null) {
7070
$node = $this->contextNode->appendChild(
7171
$this->contextNode->ownerDocument->createElementNS(
72-
'https://schema.phpunit.de/coverage/1.0',
72+
Facade::XML_NS,
7373
$name,
7474
),
7575
);

src/Report/Xml/Coverage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function finalize(array $tests): void
3030
{
3131
$writer = new XMLWriter;
3232
$writer->openMemory();
33-
$writer->startElementNs(null, $this->contextNode->nodeName, 'https://schema.phpunit.de/coverage/1.0');
33+
$writer->startElementNs(null, $this->contextNode->nodeName, Facade::XML_NS);
3434
$writer->writeAttribute('nr', $this->line);
3535

3636
foreach ($tests as $test) {

src/Report/Xml/Facade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*/
4444
final class Facade
4545
{
46+
public const string XML_NS = 'https://schema.phpunit.de/coverage/1.0';
4647
private string $target;
4748
private Project $project;
4849
private readonly string $phpUnitVersion;

src/Report/Xml/File.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function totals(): Totals
3434
if ($totalsContainer === null) {
3535
$totalsContainer = $this->contextNode->appendChild(
3636
$this->dom->createElementNS(
37-
'https://schema.phpunit.de/coverage/1.0',
37+
Facade::XML_NS,
3838
'totals',
3939
),
4040
);
@@ -48,22 +48,22 @@ public function totals(): Totals
4848
public function lineCoverage(string $line): Coverage
4949
{
5050
$coverage = $this->contextNode->getElementsByTagNameNS(
51-
'https://schema.phpunit.de/coverage/1.0',
51+
Facade::XML_NS,
5252
'coverage',
5353
)->item(0);
5454

5555
if ($coverage === null) {
5656
$coverage = $this->contextNode->appendChild(
5757
$this->dom->createElementNS(
58-
'https://schema.phpunit.de/coverage/1.0',
58+
Facade::XML_NS,
5959
'coverage',
6060
),
6161
);
6262
}
6363

6464
$lineNode = $coverage->appendChild(
6565
$this->dom->createElementNS(
66-
'https://schema.phpunit.de/coverage/1.0',
66+
Facade::XML_NS,
6767
'line',
6868
),
6969
);

src/Report/Xml/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function totals(): Totals
3838
if ($totalsContainer === null) {
3939
$totalsContainer = $this->contextNode()->appendChild(
4040
$this->dom->createElementNS(
41-
'https://schema.phpunit.de/coverage/1.0',
41+
Facade::XML_NS,
4242
'totals',
4343
),
4444
);
@@ -52,7 +52,7 @@ public function totals(): Totals
5252
public function addDirectory(string $name): Directory
5353
{
5454
$dirNode = $this->dom()->createElementNS(
55-
'https://schema.phpunit.de/coverage/1.0',
55+
Facade::XML_NS,
5656
'directory',
5757
);
5858

@@ -65,7 +65,7 @@ public function addDirectory(string $name): Directory
6565
public function addFile(string $name, string $href): File
6666
{
6767
$fileNode = $this->dom()->createElementNS(
68-
'https://schema.phpunit.de/coverage/1.0',
68+
Facade::XML_NS,
6969
'file',
7070
);
7171

src/Report/Xml/Project.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ public function projectSourceDirectory(): string
3535
public function buildInformation(): BuildInformation
3636
{
3737
$buildNode = $this->dom()->getElementsByTagNameNS(
38-
'https://schema.phpunit.de/coverage/1.0',
38+
Facade::XML_NS,
3939
'build',
4040
)->item(0);
4141

4242
if ($buildNode === null) {
4343
$buildNode = $this->dom()->documentElement->appendChild(
4444
$this->dom()->createElementNS(
45-
'https://schema.phpunit.de/coverage/1.0',
45+
Facade::XML_NS,
4646
'build',
4747
),
4848
);
@@ -56,14 +56,14 @@ public function buildInformation(): BuildInformation
5656
public function tests(): Tests
5757
{
5858
$testsNode = $this->contextNode()->getElementsByTagNameNS(
59-
'https://schema.phpunit.de/coverage/1.0',
59+
Facade::XML_NS,
6060
'tests',
6161
)->item(0);
6262

6363
if ($testsNode === null) {
6464
$testsNode = $this->contextNode()->appendChild(
6565
$this->dom()->createElementNS(
66-
'https://schema.phpunit.de/coverage/1.0',
66+
Facade::XML_NS,
6767
'tests',
6868
),
6969
);
@@ -86,7 +86,7 @@ private function init(): void
8686

8787
$this->setContextNode(
8888
$dom->getElementsByTagNameNS(
89-
'https://schema.phpunit.de/coverage/1.0',
89+
Facade::XML_NS,
9090
'project',
9191
)->item(0),
9292
);

src/Report/Xml/Report.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct(string $name)
2626
$dom->loadXML('<?xml version="1.0" ?><phpunit xmlns="https://schema.phpunit.de/coverage/1.0"><file /></phpunit>');
2727

2828
$contextNode = $dom->getElementsByTagNameNS(
29-
'https://schema.phpunit.de/coverage/1.0',
29+
Facade::XML_NS,
3030
'file',
3131
)->item(0);
3232

@@ -44,7 +44,7 @@ public function functionObject(string $name): Method
4444
{
4545
$node = $this->contextNode()->appendChild(
4646
$this->dom()->createElementNS(
47-
'https://schema.phpunit.de/coverage/1.0',
47+
Facade::XML_NS,
4848
'function',
4949
),
5050
);
@@ -67,14 +67,14 @@ public function traitObject(string $name): Unit
6767
public function source(): Source
6868
{
6969
$source = $this->contextNode()->getElementsByTagNameNS(
70-
'https://schema.phpunit.de/coverage/1.0',
70+
Facade::XML_NS,
7171
'source',
7272
)->item(0);
7373

7474
if ($source === null) {
7575
$source = $this->contextNode()->appendChild(
7676
$this->dom()->createElementNS(
77-
'https://schema.phpunit.de/coverage/1.0',
77+
Facade::XML_NS,
7878
'source',
7979
),
8080
);
@@ -95,7 +95,7 @@ private function unitObject(string $tagName, string $name): Unit
9595
{
9696
$node = $this->contextNode()->appendChild(
9797
$this->dom()->createElementNS(
98-
'https://schema.phpunit.de/coverage/1.0',
98+
Facade::XML_NS,
9999
$tagName,
100100
),
101101
);

src/Report/Xml/Tests.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function addTest(string $test, array $result): void
3434
{
3535
$node = $this->contextNode->appendChild(
3636
$this->contextNode->ownerDocument->createElementNS(
37-
'https://schema.phpunit.de/coverage/1.0',
37+
Facade::XML_NS,
3838
'test',
3939
),
4040
);

src/Report/Xml/Totals.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,27 @@ public function __construct(DOMElement $container)
2929
$dom = $container->ownerDocument;
3030

3131
$this->linesNode = $dom->createElementNS(
32-
'https://schema.phpunit.de/coverage/1.0',
32+
Facade::XML_NS,
3333
'lines',
3434
);
3535

3636
$this->methodsNode = $dom->createElementNS(
37-
'https://schema.phpunit.de/coverage/1.0',
37+
Facade::XML_NS,
3838
'methods',
3939
);
4040

4141
$this->functionsNode = $dom->createElementNS(
42-
'https://schema.phpunit.de/coverage/1.0',
42+
Facade::XML_NS,
4343
'functions',
4444
);
4545

4646
$this->classesNode = $dom->createElementNS(
47-
'https://schema.phpunit.de/coverage/1.0',
47+
Facade::XML_NS,
4848
'classes',
4949
);
5050

5151
$this->traitsNode = $dom->createElementNS(
52-
'https://schema.phpunit.de/coverage/1.0',
52+
Facade::XML_NS,
5353
'traits',
5454
);
5555

src/Report/Xml/Unit.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function setCrap(float $crap): void
4141
public function setNamespace(string $namespace): void
4242
{
4343
$node = $this->contextNode->getElementsByTagNameNS(
44-
'https://schema.phpunit.de/coverage/1.0',
44+
Facade::XML_NS,
4545
'namespace',
4646
)->item(0);
4747

4848
if ($node === null) {
4949
$node = $this->contextNode->appendChild(
5050
$this->contextNode->ownerDocument->createElementNS(
51-
'https://schema.phpunit.de/coverage/1.0',
51+
Facade::XML_NS,
5252
'namespace',
5353
),
5454
);
@@ -63,7 +63,7 @@ public function addMethod(string $name): Method
6363
{
6464
$node = $this->contextNode->appendChild(
6565
$this->contextNode->ownerDocument->createElementNS(
66-
'https://schema.phpunit.de/coverage/1.0',
66+
Facade::XML_NS,
6767
'method',
6868
),
6969
);

0 commit comments

Comments
 (0)