PHP Class Prewk\XmlStringStreamer\Parser\UniqueNode

Inheritance: implements Prewk\XmlStringStreamer\ParserInterface
Datei anzeigen Open project: prewk/xml-string-streamer Class Usage Examples

Protected Properties

Property Type Description
$containerXml string If extractContainer is true, this will grow with the XML captured before and after the specified capture depth
$preCapture boolean Whether we're found our first capture target or not

Public Methods

Method Description
__construct ( array $options = [] ) Parser constructor
getExtractedContainer ( ) : string Get the extracted container XML, if called before the whole stream is parsed, the XML returned can be invalid due to missing closing tags
getNodeFrom ( Prewk\XmlStringStreamer\StreamInterface $stream ) : string | boolean Tries to retrieve the next node or returns false

Protected Methods

Method Description
flush ( integer $endPositionInBlob ) Cut everything from the start position to the end position in the workingBlob (+ tag length) and flush it out for later return in getNodeFrom
getClosingTagPos ( ) : boolean | integer Search the blob for our unique node's closing tag
getOpeningTagPos ( ) : boolean | integer Search the blob for our unique node's opening tag
prepareChunk ( Prewk\XmlStringStreamer\StreamInterface $stream ) : boolean Decides whether we're to fetch more chunks from the stream or keep working with what we have.
startSalvaging ( integer $startPositionInBlob ) Set the start position in the workingBlob from where we should start reading when the closing tag is found

Private Methods

Method Description
checkShortClosingTag ( string $workingBlob, integer $len ) : boolean | integer Search short closing tag in $workingBlob before

Method Details

__construct() public method

Parser constructor
public __construct ( array $options = [] )
$options array An options array

flush() protected method

Cut everything from the start position to the end position in the workingBlob (+ tag length) and flush it out for later return in getNodeFrom
protected flush ( integer $endPositionInBlob )
$endPositionInBlob integer Position of the closing tag

getClosingTagPos() protected method

Search the blob for our unique node's closing tag
protected getClosingTagPos ( ) : boolean | integer
return boolean | integer Either returns the char position of the closing tag or false

getExtractedContainer() public method

Get the extracted container XML, if called before the whole stream is parsed, the XML returned can be invalid due to missing closing tags
public getExtractedContainer ( ) : string
return string XML string

getNodeFrom() public method

Tries to retrieve the next node or returns false
public getNodeFrom ( Prewk\XmlStringStreamer\StreamInterface $stream ) : string | boolean
$stream Prewk\XmlStringStreamer\StreamInterface The stream to use
return string | boolean The next xml node or false if one could not be retrieved

getOpeningTagPos() protected method

Search the blob for our unique node's opening tag
protected getOpeningTagPos ( ) : boolean | integer
return boolean | integer Either returns the char position of the opening tag or false

prepareChunk() protected method

Decides whether we're to fetch more chunks from the stream or keep working with what we have.
protected prepareChunk ( Prewk\XmlStringStreamer\StreamInterface $stream ) : boolean
$stream Prewk\XmlStringStreamer\StreamInterface The stream provider
return boolean Keep working?

startSalvaging() protected method

Set the start position in the workingBlob from where we should start reading when the closing tag is found
protected startSalvaging ( integer $startPositionInBlob )
$startPositionInBlob integer Position of starting tag

Property Details

$containerXml protected_oe property

If extractContainer is true, this will grow with the XML captured before and after the specified capture depth
protected string $containerXml
return string

$preCapture protected_oe property

Whether we're found our first capture target or not
protected bool $preCapture
return boolean