API / Minn\Feed / Document

Document final readonly class

Minn\Feed\Document · public/minn/src/Minn/Feed/Document.php · 114 lines

A parsed feed: the tree and the format it was recognized as (the reference's type bits: RSS 0.90 1, the 0.9x versions 2 to 32, RSS 1.0 64, RSS 2.0 128, Atom 0.3 256, Atom 1.0 512), with the lookups the feed object is built on: the root's children, the channel's, the image's, and the items of every format the document carries.

Constants and properties

constNONE = 0
constRSS_090 = 1
constRSS_10 = 64
constRSS_20 = 128
constATOM_03 = 256
constATOM_10 = 512
constRDF = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
privateRSS_VERSIONS = array ( '0.91' => 4, '0.92' => 8, '0.93' => 16, '0.94' => 32, )
propreadonly array $tree

Promoted from the constructor.

propreadonly int $type

Promoted from the constructor.

Public

new__construct(array $tree, int $type)#
$treearray{child?: array<string, mixed>}
staticparse(string $body, string $contentType = ''): self#

A document read from bytes; the type is NONE when it parsed but is no feed.

staticfromTree(array $tree): self#

A document over a tree already parsed (a cached feed), its type read from the root.

$treearray{child?: array<string, mixed>}
methodroot(): ?array#

The root element (rss, rdf:RDF or feed), or null.

methodchannel(): ?array#

The channel element: an RSS channel, or the Atom feed itself.

methodimage(): ?array#

The image element: inside an RSS 2.0 channel, beside an RSS 1.0 one.

methodfeedTags(string $ns, string $tag): ?array#

Children of the root element by namespace and name, or null.

methodchannelTags(string $ns, string $tag): ?array#

Children of the channel by namespace and name, or null.

methodimageTags(string $ns, string $tag): ?array#

Children of the image by namespace and name, or null.

methoditems(): array#

Every item node, in document order: Atom 1.0 and 0.3 entries, RSS 1.0 and 0.90 items beside the channel, RSS 2.0 items inside it.

@return list<array<string, mixed>>