Skip to content

Commit

Permalink
Removed conversion from xml to array
Browse files Browse the repository at this point in the history
Abstracted this functionality to another package since it is outside
the scope of the package's goal.
  • Loading branch information
mtownsend5512 committed Oct 17, 2018
1 parent ae22ed3 commit eb95b5e
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 118 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ $xml = $collection->toSoapXml('Request', 'xmlBody', 'https://yourwebserver/servi

**Please note:** the SoapFactory class will ping the ``$fullUrl`` to see if it is valid as it builds the SOAP xml. It will not trigger an api interaction, but you will experience an exception if your url is invalid.

### Xml to collection

Convert valid xml into an array before wrapping it in a collection:

```php
$xml = '<?xml version="1.0"?><root><carrier>fedex</carrier><id>123</id><tracking_number>9205590164917312751089</tracking_number></root>';

$collection = collect(xml_to_array($xml));
```

### Array to xml

Convert an array into xml without using a collection:
Expand All @@ -80,12 +70,6 @@ $xml = array_to_xml($array);

The ``$root`` argument allows you to customize the root xml element. Default is ``<root>``.

**Helper**

``xml_to_array($xml, $outputRoot = false)``

The ``$outputRoot`` determines whether or not the php array will have a ``@root`` key. Default is ``false``.

**Collection method**

``->toXml($root)``
Expand Down
82 changes: 0 additions & 82 deletions src/XmlToArray.php

This file was deleted.

14 changes: 0 additions & 14 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,3 @@ function array_to_xml($array, $root = '')
return \Spatie\ArrayToXml\ArrayToXml::convert($array, $root);
}
}

if (!function_exists('xml_to_array')) {
/**
* Convert valid XML to an array.
*
* @param string $xml
* @param bool $outputRoot
* @return array
*/
function xml_to_array($xml, $outputRoot = false)
{
return \Mtownsend\CollectionXml\XmlToArray::convert($xml, $outputRoot);
}
}
6 changes: 0 additions & 6 deletions tests/CollectionXmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,4 @@ public function array_can_convert_to_xml()
$xml = $this->removeNewLines(array_to_xml($array));
$this->assertEquals($xml, $this->testXml);
}

/** @test */
public function xml_can_convert_to_array()
{
$this->assertEquals(xml_to_array($this->testXml), $this->testCollection->toArray());
}
}

0 comments on commit eb95b5e

Please sign in to comment.