1
0
mirror of https://github.com/Chouchen/ShikiryuRSS.git synced 2025-11-01 02:43:08 +01:00

🚧 Add some validations and corrections

This commit is contained in:
Shikiryu
2023-04-11 23:49:03 +02:00
parent 5de5993e2b
commit f1816dec0c
10 changed files with 48 additions and 26 deletions

View File

@@ -3,6 +3,7 @@
namespace Shikiryu\SRSS\Parser;
use DOMDocument;
use DOMNode;
use DOMNodeList;
use DOMXPath;
use Shikiryu\SRSS\Entity\Channel;
@@ -39,8 +40,8 @@ class SRSSParser extends DomDocument
/**
* @param string $link
*
* @return \Shikiryu\SRSS\SRSS
* @throws \Shikiryu\SRSS\Exception\SRSSException
* @return SRSS
* @throws SRSSException
*/
public function parse(string $link)
{
@@ -48,7 +49,7 @@ class SRSSParser extends DomDocument
$channel = $this->getElementsByTagName('channel');
if($channel->length === 1){ // Good URL and good RSS
$this->_loadAttributes(); // loading channel properties
$this->getItems(); // loading all items
$this->parseItems(); // loading all items
return $this->doc;
}
@@ -61,9 +62,9 @@ class SRSSParser extends DomDocument
/**
* @return Item[]
* @throws \Shikiryu\SRSS\Exception\SRSSException
* @throws SRSSException
*/
private function getItems(): array
private function parseItems(): array
{
$channel = $this->_getChannel();
/** @var DOMNodeList $items */
@@ -108,10 +109,10 @@ class SRSSParser extends DomDocument
/**
* getter of current RSS channel
* @return \DOMNode
* @return DOMNode
* @throws SRSSException
*/
private function _getChannel(): \DOMNode
private function _getChannel(): DOMNode
{
$channel = $this->getElementsByTagName('channel');
if($channel->length != 1) {