Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Imangazaliev committed Mar 16, 2016
1 parent 8f3dba5 commit e492fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/DiDom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace DiDom;

use DOMDocument;
use DOMElement;
use DOMXPath;
use InvalidArgumentException;
use RuntimeException;
Expand Down Expand Up @@ -66,11 +65,11 @@ public function createElement($name, $value = '', $attributes = [])
/**
* Adds new child at the end of the children.
*
* @param \DiDom\Element|\DOMElement|array $nodes The appended child.
* @param \DiDom\Element|\DOMNode|array $nodes The appended child.
*
* @return \DiDom\Document
*
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
*/
public function appendChild($nodes)
{
Expand All @@ -81,8 +80,8 @@ public function appendChild($nodes)
$node = $node->getNode();
}

if (!$node instanceof DOMElement) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMElement, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
if (!$node instanceof \DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMNode, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
}

$this->displayErrors(false);
Expand Down
14 changes: 7 additions & 7 deletions src/DiDom/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ public function __construct($name, $value = '', $attributes = [])
/**
* Adds new child at the end of the children.
*
* @param \DiDom\Element|\DOMElement|array $nodes The appended child.
* @param \DiDom\Element|\DOMNode|array $nodes The appended child.
*
* @return \DiDom\Element
*
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMElement or \DiDom\Element
* @throws \InvalidArgumentException if the provided argument is not an instance of \DOMNode or \DiDom\Element
*/
public function appendChild($nodes)
{
Expand All @@ -58,8 +58,8 @@ public function appendChild($nodes)
$node = $node->getNode();
}

if (!$node instanceof DOMElement) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMElement, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
if (!$node instanceof \DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s\Element or DOMNode, %s given', __METHOD__, __NAMESPACE__, (is_object($node) ? get_class($node) : gettype($node))));
}

libxml_use_internal_errors(true);
Expand Down Expand Up @@ -220,12 +220,12 @@ public function innerHtml($options = 0)

foreach ($children as $child)
{
$childrenHtml[] = trim($child->ownerDocument->saveXml($child, $options));
$childrenHtml[] = $child->ownerDocument->saveXml($child, $options);
}

$html = implode(PHP_EOL, $childrenHtml);
$html = implode('', $childrenHtml);

return str_replace('
', '', $html);
return html_entity_decode($html);
}

/**
Expand Down

0 comments on commit e492fea

Please sign in to comment.