Skip to content

Commit 2e5539c

Browse files
committed
Throw an exception if the PHP value provided to DateTimeMapping is not a Carbon instance
1 parent 8549f65 commit 2e5539c

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/Soap/DateTimeMapping.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Carbon\Carbon;
66
use SimpleXMLElement;
7+
use InvalidArgumentException;
78
use Pace\Contracts\Soap\TypeMapping;
89

910
class DateTimeMapping implements TypeMapping
@@ -55,6 +56,10 @@ public function fromXml($xml)
5556
*/
5657
public function toXml($php)
5758
{
59+
if (!$php instanceof Carbon) {
60+
throw new InvalidArgumentException('PHP value must be a Carbon instance');
61+
}
62+
5863
return sprintf(
5964
'<%1$s>%2$s</%1$s>',
6065
$this->getTypeName(),

0 commit comments

Comments
 (0)