Common and useful classes, methods, exceptions etc.
Meritoo\Common\Collection\Templates
Collection/storage of templates, instance of Meritoo\Common\ValueObject\Template
class.
New instance can be created using:
-
Constructor:
new Templates([ 'first' => new Template('First name: %first_name%'), 'last' => new Template('Last name: %last_name%'), ]);
-
Static method
fromArray(array $templates)
- creates and returns the collection from given arrayTemplates::fromArray([ 'first' => 'First name: %first_name%', 'last' => 'Last name: %last_name%', ]);
Has all methods of parent class Meritoo\Common\Collection\Collection
+ findTemplate(string $index)
method that finds
and returns template with given index.
Example of usage:
$templates = new Templates([
'first' => new Template('First name: %first_name%'),
'last' => new Template('Last name: %last_name%'),
]);
$template = $templates->findTemplate('first'); // new Template('First name: %first_name%')
Throws an Meritoo\Common\Exception\ValueObject\Template\TemplateNotFoundException
exception if template with given
index was not found.