Skip to content

Commit e46df26

Browse files
committed
nipicks
1 parent 934a2a9 commit e46df26

17 files changed

+9
-107
lines changed

src/ArrayToXml.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,9 @@ public static function convert(
7878

7979
public function toXml(): string
8080
{
81-
if ($this->addXmlDeclaration === false) {
82-
return $this->document->saveXml($this->document->documentElement);
83-
}
84-
85-
return $this->document->saveXML();
81+
return $this->addXmlDeclaration
82+
? $this->document->saveXML()
83+
: $this->document->saveXml($this->document->documentElement);
8684
}
8785

8886
public function toDom(): DOMDocument
@@ -94,7 +92,7 @@ protected function ensureValidDomProperties(array $domProperties): void
9492
{
9593
foreach ($domProperties as $key => $value) {
9694
if (! property_exists($this->document, $key)) {
97-
throw new Exception($key.' is not a valid property of DOMDocument');
95+
throw new Exception("{$key} is not a valid property of DOMDocument");
9896
}
9997
}
10098
}
@@ -125,10 +123,7 @@ public function dropXmlDeclaration(): self
125123
return $this;
126124
}
127125

128-
/**
129-
* @param mixed[]|mixed $value
130-
*/
131-
private function convertElement(DOMElement $element, $value): void
126+
protected function convertElement(DOMElement $element, mixed $value): void
132127
{
133128
$sequential = $this->isArrayAllKeySequential($value);
134129

@@ -213,10 +208,7 @@ protected function addSequentialNode(DOMElement $element, $value): void
213208
$element->parentNode->appendChild($child);
214209
}
215210

216-
/**
217-
* @return bool|mixed[]
218-
*/
219-
protected function isArrayAllKeySequential(array | string $value): mixed
211+
protected function isArrayAllKeySequential(array | string $value): bool
220212
{
221213
if (! is_array($value)) {
222214
return false;

tests/ArrayToXmlTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ class ArrayToXmlTest extends TestCase
88
{
99
use MatchesSnapshots;
1010

11-
/** @test array */
12-
protected $testArray = [];
11+
protected array $testArray = [];
1312

1413
public function setUp(): void
1514
{
@@ -274,7 +273,7 @@ public function it_can_handle_values_set_as_cdata()
274273
}
275274

276275
/** @test */
277-
public function and_cdata_values_can_also_be_set_in_simplexmlelement_style()
276+
public function and_cdata_values_can_also_be_set_in_simplexml_element_style()
278277
{
279278
$this->assertMatchesSnapshot(ArrayToXml::convert([
280279
'movie' => [
@@ -341,7 +340,7 @@ public function it_can_handle_values_set_as_mixed()
341340
}
342341

343342
/** @test */
344-
public function and_mixed_values_can_also_be_set_in_simplexmlelement_style()
343+
public function and_mixed_values_can_also_be_set_in_simplexml_element_style()
345344
{
346345
$this->assertMatchesSnapshot(ArrayToXml::convert([
347346
'movie' => [

tests/__snapshots__/ArrayToXmlTest__and_cdata_values_can_also_be_set_in_simplexmlelement_style__1.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/__snapshots__/ArrayToXmlTest__and_mixed_values_can_also_be_set_in_simplexmlelement_style__1.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_standalone_value__1.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/__snapshots__/ArrayToXmlTest__it_accepts_an_xml_version__1.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/__snapshots__/ArrayToXmlTest__it_can_drop_xml_declaration__1.php

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/__snapshots__/ArrayToXmlTest__it_can_handle_custom_keys__1.php

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)