Skip to content

Commit abb1f52

Browse files
committed
Fix for #22 - Add support to invoke getLastRequest without throwing an InvalidArgumentException if the request is not executed.
1 parent 7797438 commit abb1f52

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Utils.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ class Utils
1313
*/
1414
public static function getFormatedXml($string, $asDomDocument = false)
1515
{
16-
$domDocument = self::getDOMDocument($string);
17-
return $asDomDocument ? $domDocument : $domDocument->saveXML();
16+
if (!is_null($string)) {
17+
$domDocument = self::getDOMDocument($string);
18+
return $asDomDocument ? $domDocument : $domDocument->saveXML();
19+
}
20+
return null;
1821
}
1922
/**
2023
* @param string $string

tests/UtilsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,20 @@ public function testGetFormatedXmlInvalidXmlAsDomDocument()
4141
{
4242
Utils::getFormatedXml('<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:img="http://ws.estesexpress.com/imageview" attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://ws.estesexpress.com/imageview" xml:lang="en"><root>', true);
4343
}
44+
/**
45+
*
46+
*/
47+
public function testGetFormatedXmlNullAsString()
48+
{
49+
$this->assertNull(Utils::getFormatedXml(null));
50+
}
51+
/**
52+
*
53+
*/
54+
public function testGetFormatedXmlNullAsDomDocument()
55+
{
56+
$this->assertNull(Utils::getFormatedXml(null, true));
57+
}
4458
/**
4559
*
4660
*/

0 commit comments

Comments
 (0)