Skip to content

Commit 4bdd98f

Browse files
committed
Finish refactoring to UserDoc and DevDoc with domain-appropriate names
1 parent f276ad6 commit 4bdd98f

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

src/Parser/UserDocParser.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55

66
use App\Value\Diff;
77
use App\Value\Url;
8-
use App\Value\XmlParts;
8+
use App\Value\UserDoc;
99
use SimpleXMLElement;
1010
use Stringy\Stringy as s;
1111

1212
class UserDocParser
1313
{
14-
public function getManualParts(string $filePath): XmlParts
14+
public function getUserDoc(string $filePath): UserDoc
1515
{
1616
$doc = new SimpleXMLElement(file_get_contents($filePath));
1717

18-
return new XmlParts(
18+
return new UserDoc(
1919
$this->getRuleCode($doc),
2020
$this->getDescription($doc),
2121
$this->getDiffs($doc),

src/Value/XmlParts.php renamed to src/Value/UserDoc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
namespace App\Value;
55

6-
class XmlParts
6+
class UserDoc
77
{
88
private string $ruleCode;
99
private string $description;

tests/Parser/DevDocParserTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected function setUp(): void
2020
}
2121

2222
/** @test */
23-
public function getManualParts_WithDocblockSummary_AddSummaryOnly()
23+
public function getDevDoc_WithDocblockSummary_AddSummaryOnly()
2424
{
2525
$content = '<?php
2626
/**
@@ -32,15 +32,15 @@ class MySniff {}
3232
';
3333

3434
file_put_contents(self::PHP_FILE_PATH, $content);
35-
$parts = $this->parser->getDevDoc(self::PHP_FILE_PATH);
35+
$doc = $this->parser->getDevDoc(self::PHP_FILE_PATH);
3636
self::assertEquals(
3737
"Summary\nLine 2",
38-
$parts->getDocblock()
38+
$doc->getDocblock()
3939
);
4040
}
4141

4242
/** @test */
43-
public function getManualParts_WithProperties_AddPublicOnly()
43+
public function getDevDoc_WithProperties_AddPublicOnly()
4444
{
4545
$content = '<?php
4646
class MySniff {
@@ -55,20 +55,20 @@ class MySniff {
5555
';
5656

5757
file_put_contents(self::PHP_FILE_PATH, $content);
58-
$parts = $this->parser->getDevDoc(self::PHP_FILE_PATH);
58+
$doc = $this->parser->getDevDoc(self::PHP_FILE_PATH);
5959
self::assertEquals(
6060
[
6161
new Property('boolProperty', 'bool'),
6262
new Property('stringProperty', 'string'),
6363
new Property('mixedProperty', 'mixed'),
6464
new Property('unionProperty', 'string|null'),
6565
],
66-
$parts->getProperties()
66+
$doc->getProperties()
6767
);
6868
}
6969

7070
/** @test */
71-
public function getManualParts_WithMultipleLinks_AddLinks()
71+
public function getDevDoc_WithMultipleLinks_AddLinks()
7272
{
7373
$content = '<?php
7474
/**
@@ -79,13 +79,13 @@ class MySniff {}
7979
';
8080

8181
file_put_contents(self::PHP_FILE_PATH, $content);
82-
$parts = $this->parser->getDevDoc(self::PHP_FILE_PATH);
82+
$doc = $this->parser->getDevDoc(self::PHP_FILE_PATH);
8383
self::assertEquals(
8484
[
8585
new Url('http://link1.com'),
8686
new Url('http://link2.com')
8787
],
88-
$parts->getLinks()
88+
$doc->getLinks()
8989
);
9090
}
9191
}

tests/Parser/UserDocParserTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use App\Parser\UserDocParser;
77
use App\Value\Diff;
88
use App\Value\Url;
9-
use App\Value\XmlParts;
9+
use App\Value\UserDoc;
1010
use PHPUnit\Framework\TestCase;
1111

1212
/** @covers \App\Parser\UserDocParser */
@@ -21,7 +21,7 @@ protected function setUp(): void
2121
}
2222

2323
/** @test */
24-
public function getManualParts_WithMinimumTags_CreatePartsObject()
24+
public function getUserDoc_WithMinimumTags_CreateUserDocObject()
2525
{
2626
$content = <<<XML
2727
<documentation title="Title">
@@ -30,20 +30,20 @@ public function getManualParts_WithMinimumTags_CreatePartsObject()
3030
</documentation>
3131
XML;
3232
file_put_contents(self::XML_FILE_PATH, $content);
33-
$parts = $this->parser->getManualParts(self::XML_FILE_PATH);
33+
$doc = $this->parser->getUserDoc(self::XML_FILE_PATH);
3434
self::assertEquals(
35-
new XmlParts(
35+
new UserDoc(
3636
'Rule.Code',
3737
'Description',
3838
[],
3939
[]
4040
),
41-
$parts
41+
$doc
4242
);
4343
}
4444

4545
/** @test */
46-
public function getManualParts_WithCodeComparisons_AddTrimmedDiffs()
46+
public function getUserDoc_WithCodeComparisons_AddTrimmedDiffs()
4747
{
4848
$content = <<<XML
4949
<documentation title="Title">
@@ -70,18 +70,18 @@ function b() {
7070
</documentation>
7171
XML;
7272
file_put_contents(self::XML_FILE_PATH, $content);
73-
$parts = $this->parser->getManualParts(self::XML_FILE_PATH);
73+
$doc = $this->parser->getUserDoc(self::XML_FILE_PATH);
7474
self::assertEquals(
7575
[
7676
new Diff("function a() {\n}", "function b() {\n}"),
7777
new Diff('a();', 'b();'),
7878
],
79-
$parts->getDiffs()
79+
$doc->getDiffs()
8080
);
8181
}
8282

8383
/** @test */
84-
public function getManualParts_WithLinks_AddLinks()
84+
public function getUserDoc_WithLinks_AddLinks()
8585
{
8686
$content = <<<XML
8787
<documentation title="Title">
@@ -94,13 +94,13 @@ public function getManualParts_WithLinks_AddLinks()
9494
</documentation>
9595
XML;
9696
file_put_contents(self::XML_FILE_PATH, $content);
97-
$parts = $this->parser->getManualParts(self::XML_FILE_PATH);
97+
$doc = $this->parser->getUserDoc(self::XML_FILE_PATH);
9898
self::assertEquals(
9999
[
100100
new Url('http://link1.com'),
101101
new Url('http://link2.com')
102102
],
103-
$parts->getLinks()
103+
$doc->getLinks()
104104
);
105105
}
106106
}

0 commit comments

Comments
 (0)