class Atom extends AbstractXmlMiddleware implements XmlInterface, SetLoggerInterface (View source)

Support for the Atom 1.0 grammar.

Traits

Shared code for working with the logger.
Shared code for working with the logger.

Properties

protected LoggerInterface $logger A PSR-3 logger. from LoggerTrait
protected callable $fn A callable which is used to determine whether or not to run this middleware. from AbstractMiddleware
protected bool $caseSensitive The status of case-sensitivity. from AbstractXmlMiddleware

Methods

setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

getLogger()

Retrieves the PSR-3 logger.

__construct(callable|null $fn = null)

Constructs a new instance of this class.

void
addArrayProperty(mixed $object, string $property)

Checks whether or not a particular property exists on an object, and if not, instantiates it as an array.

get(array $arr, string $key, mixed $default = null)

Return the value of an associative array key, if it exists. If not, return $default.

setCaseInsensitive(bool $makeInsensitive = true)

By default, SimplePie NG is case-sensitive (as per the specification). If an invalid feed is parsed that does not follow the specification with regard to casing of XML elements, this method allows you to trade some performance in favor of case-insensitive parsing.

string
applyNsToQuery(string $query, string $namespaceAlias)

Replace all instances of %s with the $namespaceAlias parameter.

string
generateQuery(string $namespaceAlias, array $path)

Produce an XPath 1.0 expression which is used to query XML document nodes.

void
__invoke(stdClass $feedRoot, string $namespaceAlias, DOMXPath $xpath)

The function signature for the middleware.

array
getSupportedNamespaces()

Gets the list of supported namespaces and their namespace aliases.

void
getNodeAttributes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path, array $fallback = [])

Fetches attributes with a single, scalar value, on elements.

void
getSingleScalarTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path, array $fallback = [])

Fetches elements with a single, scalar value.

void
getSingleComplexTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path)

Fetches elements with a single, complex value.

void
getMultipleComplexTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path)

Fetches elements with a multiple, complex values.

Details

LoggerTrait setLogger(LoggerInterface $logger)

Sets the PSR-3 logger.

Parameters

LoggerInterface $logger A PSR-3 compatible logger.

Return Value

LoggerTrait

LoggerInterface getLogger()

Retrieves the PSR-3 logger.

Return Value

LoggerInterface

__construct(callable|null $fn = null)

Constructs a new instance of this class.

Accepts a callable with the following function signature:

function () {}

Parameters

callable|null $fn A callable which is used to determine whether or not to run this middleware. A value of true means that the middleware should run. A value of false means that the middleware should NOT run, By default, the middleware will run.

void addArrayProperty(mixed $object, string $property)

Checks whether or not a particular property exists on an object, and if not, instantiates it as an array.

Parameters

mixed $object An object that you can add ad-hoc properties to. Preferably a stdClass object.
string $property The name of the property to check and/or add.

Return Value

void

get(array $arr, string $key, mixed $default = null)

Return the value of an associative array key, if it exists. If not, return $default.

Parameters

array $arr The associative array to check.
string $key The key in the associative array to return the value for.
mixed $default The default value to return if there is no value. The default value is null.

AbstractXmlMiddleware setCaseInsensitive(bool $makeInsensitive = true)

By default, SimplePie NG is case-sensitive (as per the specification). If an invalid feed is parsed that does not follow the specification with regard to casing of XML elements, this method allows you to trade some performance in favor of case-insensitive parsing.

Parameters

bool $makeInsensitive Whether or not the handling should be made case-insensitive. A value of true means that the handling should be case-insensitive. A value of false means that the handling should be case-sensitive. The default value is true.

Return Value

AbstractXmlMiddleware

string applyNsToQuery(string $query, string $namespaceAlias)

Replace all instances of %s with the $namespaceAlias parameter.

This is similar to sprintf(), but the $namespaceAlias is applied to all instances of %s.

Parameters

string $query An XPath query where %s is used in-place of the XML namespace alias.
string $namespaceAlias The XML namespace alias to apply.

Return Value

string

string generateQuery(string $namespaceAlias, array $path)

Produce an XPath 1.0 expression which is used to query XML document nodes.

['feed', 'entry', 5, 'id', '@xml:lang']
/feed/entry[5]/id/@xml:lang (simplified)

Parameters

string $namespaceAlias The XML namespace alias to apply.
array $path An ordered array of nested elements, starting from the top-level XML node. If an integer is added, then it is assumed that the element before it should be handled as an array and the integer is its index. Expression is generated left-to-right.

Return Value

string An XPath 1.0 expression.

void __invoke(stdClass $feedRoot, string $namespaceAlias, DOMXPath $xpath)

The function signature for the middleware.

Parameters

stdClass $feedRoot The root of the feed. This will be written-to when the parsing middleware runs.
string $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result of a call to SimplePie\Util\Ns.
DOMXPath $xpath The DOMXPath object with this middleware's namespace alias applied.

Return Value

void

array getSupportedNamespaces()

Gets the list of supported namespaces and their namespace aliases.

Returns an associative array where the key is the XML Namespace URL, and the value is the friendly alias name that the middleware can use to refer to it.

return [
    'http://www.w3.org/2005/Atom' => 'atom10'
];

Return Value

array

protected void getNodeAttributes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path, array $fallback = [])

Fetches attributes with a single, scalar value, on elements.

Parameters

object $feedRoot The root of the feed. This will be written-to when the parsing middleware runs.
string $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result of a call to SimplePie\Util\Ns.
DOMXPath $xpath The DOMXPath object with this middleware's namespace alias applied.
array $path The path of the XML traversal. Should begin with <feed> or <channel>, then <entry> or <item>.
array $fallback An array of attributes for default XML attributes. The default value is an empty array.

Return Value

void

protected void getSingleScalarTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path, array $fallback = [])

Fetches elements with a single, scalar value.

Parameters

object $feedRoot The root of the feed. This will be written-to when the parsing middleware runs.
string $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result of a call to SimplePie\Util\Ns.
DOMXPath $xpath The DOMXPath object with this middleware's namespace alias applied.
array $path The path of the XML traversal. Should begin with <feed> or <channel>, then <entry> or <item>.
array $fallback An array of attributes for default XML attributes. The default value is an empty array.

Return Value

void

protected void getSingleComplexTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path)

Fetches elements with a single, complex value.

Parameters

object $feedRoot The root of the feed. This will be written-to when the parsing middleware runs.
string $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result of a call to SimplePie\Util\Ns.
DOMXPath $xpath The DOMXPath object with this middleware's namespace alias applied.
array $path The path of the XML traversal. Should begin with <feed> or <channel>, then <entry> or <item>.

Return Value

void

protected void getMultipleComplexTypes(object $feedRoot, string $namespaceAlias, DOMXPath $xpath, array $path)

Fetches elements with a multiple, complex values.

Parameters

object $feedRoot The root of the feed. This will be written-to when the parsing middleware runs.
string $namespaceAlias The preferred namespace alias for a given XML namespace URI. Should be the result of a call to SimplePie\Util\Ns.
DOMXPath $xpath The DOMXPath object with this middleware's namespace alias applied.
array $path The path of the XML traversal. Should begin with <feed> or <channel>, then <entry> or <item>.

Return Value

void