Skip to content

Commit

Permalink
Code style violation fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPetterMG committed Apr 4, 2016
1 parent ee6a4b8 commit 6e711fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "vipnytt/sitemapparser",
"description": "XML Sitemap parser class compliant with the Sitemaps.org protocol.",
"version": "1.0.0",
"keywords": [
"sitemap",
"sitemaps.org",
Expand Down Expand Up @@ -44,4 +43,4 @@
"vipnytt\\SitemapParser\\Tests\\": "tests/"
}
}
}
}
11 changes: 5 additions & 6 deletions src/SitemapParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function parse($url, $urlContent = null)
$response = gzdecode($response);
}
$sitemapJson = $this->generateXMLObject($response);
if ($sitemapJson === false) {
if ($sitemapJson instanceof SimpleXMLElement === false) {
$this->parseString($response);
return;
}
Expand Down Expand Up @@ -239,13 +239,12 @@ protected function addArray($type, $array)
*/
protected function generateXMLObject($xml)
{
libxml_use_internal_errors(true);
$doc = simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
if ($doc === false) {
libxml_clear_errors();
try {
libxml_use_internal_errors(true);
return new SimpleXMLElement($xml, LIBXML_NOCDATA);
} catch (\Exception $e) {
return false;
}
return $doc;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/ExceptionEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ExceptionEncodingTest extends \PHPUnit_Framework_TestCase
{
/**
* Test if exception is thrown when extension `simpleXML` is not loaded
* Test if exception is thrown when trying to set encoding to `UTF-8`
*/
public function testExceptionEncoding()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ExceptionMBStringTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
class ExceptionMBStringTest extends \PHPUnit_Framework_TestCase
{
/**
* Test if exception is thrown when extension `simpleXML` is not loaded
* Test if exception is thrown when extension `mbstring` is not loaded
*/
public function testExceptionMBString()
{
Expand Down

0 comments on commit 6e711fc

Please sign in to comment.