Eno\Section » element

element($name) → element or null
element($name, $options) → element or null

Retrieve a single element of any type from the section by its name. Optionally specify whether it's optional or mandatory for the element to be present in the eno document (by default it's optional).

enotitle: Artfest 2018
tags:
- art
- code

# content
> ...
php$document = Parser::parse($input);

$document->element('title');  // returns [Field name="title" value="Artfest 2018"]
$document->element('tags');  // returns [List name="tags" items=2]
$document->element('content');  // returns [Section name="content" items=14]

$document->element('fantasy');  // returns null
$document->element('fantasy', [ 'enforce_element' => true ]);  // throws a ValidationError
$document->element('fantasy', [ 'required' => true ]);  // throws a ValidationError

Parameters

$name

The name of the element to fetch from the section as a string.

$options

enforce_element

Whether the element must be present in the document (true or false, defaults to false)

required

Alias for enforce_element (this exists on many methods and depending on context refers to either element or value)

Return value

An element (e.g. ListElement, Field, etc.) or null.