mirror of
https://github.com/wiosna-dev/common-library.git
synced 2026-03-12 09:31:51 +01:00
1.7 KiB
1.7 KiB
Meritoo Common Library
Common and useful classes, methods, exceptions etc.
Templates
Namespace
Meritoo\Common\Collection\Templates
Info
Collection/storage of templates, instance of Meritoo\Common\ValueObject\Template class.
New instance
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%', ]);
Methods
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.