PHP Class PicoFeed\Parser\Parser

Author: Frederic Guillot
Inheritance: implements PicoFeed\Parser\ParserInterface
Exibir arquivo Open project: fguillot/picofeed Class Usage Examples

Protected Properties

Property Type Description
$content string Feed content (XML data).
$fallback_url string Fallback url.
$namespaces array XML namespaces supported by parser.
$used_namespaces array XML namespaces used in document.

Public Methods

Method Description
__construct ( string $content, string $http_encoding = '', string $fallback_url = '' ) Constructor.
checkFeedUrl ( PicoFeed\Parser\Feed $feed ) Check if the feed url is correct.
checkItemUrl ( PicoFeed\Parser\Feed $feed, PicoFeed\Parser\Item $item ) Check if the item url is correct.
checkSiteUrl ( PicoFeed\Parser\Feed $feed ) Check if the site url is correct.
disableContentFiltering ( ) : Parser Enable the content grabber.
enableContentGrabber ( boolean $needsRuleFile = false, null | Closure $scraperCallback = null ) : Parser Enable the content grabber.
execute ( ) : PicoFeed\Parser\Feed Parse the document.
findItemDate ( SimpleXMLElement $entry, PicoFeed\Parser\Item $item, PicoFeed\Parser\Feed $feed ) Find the item date.
generateId ( ) : string Generate a unique id for an entry (hash all arguments).
getDateParser ( ) : PicoFeed\Parser\DateParser Get DateParser instance
getItemPostProcessor ( ) : PicoFeed\Processor\ItemPostProcessor Get Item Post Processor instance
isLanguageRTL ( string $language ) : boolean Return true if the given language is "Right to Left".
registerSupportedNamespaces ( SimpleXMLElement $xml ) : SimpleXMLElement Register all supported namespaces to be used within an xpath query.
setConfig ( PicoFeed\Config\Config $config ) : Parser Set config object.
setGrabberIgnoreUrls ( array $urls ) : Parser Set ignored URLs for the content grabber.
setHashAlgo ( string $algo ) : Parser Set Hash algorithm used for id generation.

Method Details

__construct() public method

Constructor.
public __construct ( string $content, string $http_encoding = '', string $fallback_url = '' )
$content string Feed content
$http_encoding string HTTP encoding (headers)
$fallback_url string Fallback url when the feed provide relative or broken url

checkFeedUrl() public method

Check if the feed url is correct.
public checkFeedUrl ( PicoFeed\Parser\Feed $feed )
$feed PicoFeed\Parser\Feed Feed object

checkItemUrl() public method

Check if the item url is correct.
public checkItemUrl ( PicoFeed\Parser\Feed $feed, PicoFeed\Parser\Item $item )
$feed PicoFeed\Parser\Feed Feed object
$item PicoFeed\Parser\Item Item object

checkSiteUrl() public method

Check if the site url is correct.
public checkSiteUrl ( PicoFeed\Parser\Feed $feed )
$feed PicoFeed\Parser\Feed Feed object

disableContentFiltering() public method

Enable the content grabber.
public disableContentFiltering ( ) : Parser
return Parser

enableContentGrabber() public method

Enable the content grabber.
public enableContentGrabber ( boolean $needsRuleFile = false, null | Closure $scraperCallback = null ) : Parser
$needsRuleFile boolean true if only pages with rule files should be scraped
$scraperCallback null | Closure Callback function that gets called for each scraper execution
return Parser

execute() public method

Parse the document.
public execute ( ) : PicoFeed\Parser\Feed
return PicoFeed\Parser\Feed

findItemDate() public method

Find the item date.
public findItemDate ( SimpleXMLElement $entry, PicoFeed\Parser\Item $item, PicoFeed\Parser\Feed $feed )
$entry SimpleXMLElement Feed item
$item PicoFeed\Parser\Item Item object
$feed PicoFeed\Parser\Feed Feed object

generateId() public method

Generate a unique id for an entry (hash all arguments).
public generateId ( ) : string
return string

getDateParser() public method

Get DateParser instance
public getDateParser ( ) : PicoFeed\Parser\DateParser
return PicoFeed\Parser\DateParser

getItemPostProcessor() public method

Get Item Post Processor instance
public getItemPostProcessor ( ) : PicoFeed\Processor\ItemPostProcessor
return PicoFeed\Processor\ItemPostProcessor

isLanguageRTL() public static method

Return true if the given language is "Right to Left".
public static isLanguageRTL ( string $language ) : boolean
$language string Language: fr-FR, en-US
return boolean

registerSupportedNamespaces() public method

Register all supported namespaces to be used within an xpath query.
public registerSupportedNamespaces ( SimpleXMLElement $xml ) : SimpleXMLElement
$xml SimpleXMLElement Feed xml
return SimpleXMLElement

setConfig() public method

Set config object.
public setConfig ( PicoFeed\Config\Config $config ) : Parser
$config PicoFeed\Config\Config Config instance
return Parser

setGrabberIgnoreUrls() public method

Set ignored URLs for the content grabber.
public setGrabberIgnoreUrls ( array $urls ) : Parser
$urls array URLs
return Parser

setHashAlgo() public method

Set Hash algorithm used for id generation.
public setHashAlgo ( string $algo ) : Parser
$algo string Algorithm name
return Parser

Property Details

$content protected_oe property

Feed content (XML data).
protected string $content
return string

$fallback_url protected_oe property

Fallback url.
protected string $fallback_url
return string

$namespaces protected_oe property

XML namespaces supported by parser.
protected array $namespaces
return array

$used_namespaces protected_oe property

XML namespaces used in document.
protected array $used_namespaces
return array