Skip to content

Commit

Permalink
fix: getElement() should always return SimpleXMLElement
Browse files Browse the repository at this point in the history
  • Loading branch information
danmichaelo committed Jul 1, 2017
1 parent 153d256 commit a4f592e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Danmichaelo/QuiteSimpleXMLElement/QuiteSimpleXMLElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ protected function getElement($elem)
}

if (gettype($elem) == 'object') {
if (in_array(get_class($elem),
['Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement', 'SimpleXMLElement'])) {
return $elem; // assume it's a SimpleXMLElement
} else {
throw new InvalidArgumentException('Unknown object given to QuiteSimpleXMLElement. Expected SimpleXMLElement or QuiteSimpleXMLElement.');
switch (get_class($elem)) {
case 'Danmichaelo\QuiteSimpleXMLElement\QuiteSimpleXMLElement':
return $elem->el();
case 'SimpleXMLElement':
return $elem;
}
}

Expand Down

0 comments on commit a4f592e

Please sign in to comment.