\Jkphl\Micrometa\ParserMicroformats2

Extended Microformats2 parser

Summary

Methods
Properties
Constants
__construct()
parse()
isValidVocable()
decamelize()
No public properties found
No constants found
_refineResults()
$_url
N/A
No private methods found
No private properties found
N/A

Properties

Methods

__construct()

__construct(\DOMDocument|string $input, \Jkphl\Utility\Url|\string $url)

Constructor

Parameters

\DOMDocument|string $input

The data to parse. A string of HTML or a DOMDocument

\Jkphl\Utility\Url|\string $url

Optional: The URL of the parsed document, for relative URL resolution

parse()

parse(bool $convertClassic, \Jkphl\Micrometa\Parser\DOMElement $context) : array

Kicks off the parsing routine

If $convertClassic is set, any angle brackets in the results from non e-* properties will be HTML-encoded, bringing all output to the same level of encoding.

If a DOMElement is set as the $context, only descendants of that element will be parsed for microformats.

Parameters

bool $convertClassic

Whether or not to html-encode non e-* properties. Defaults to false

\Jkphl\Micrometa\Parser\DOMElement $context

Optionall: An element from which to parse microformats

Returns

array —

An array containing all the µfs found in the current document

isValidVocable()

isValidVocable(\string $str) : \boolean

Check if a string is a valid microformats2 vocable (regular or camelCased)

Parameters

\string $str

String

Returns

\boolean —

Whether it's a valid microformats2 vocable

decamelize()

decamelize(\string $vocable, \string $separator) : \string

Decamelize a lower- or UpperCameCase microformats2 vocable (has no effect on regular vocables)

Parameters

\string $vocable

Vocable

\string $separator

Separation char / vocable

Throws

\Jkphl\Micrometa\Parser\Microformats2\Exception

If it's not a valid microformats2 vocable

Returns

\string —

Decamelized vocable

_refineResults()

_refineResults(\array $results) : \array

Refine micro information items

Parameters

\array $results

Micro information items

Returns

\array —

Refined micro information items