Skip to content

Latest commit

 

History

History
67 lines (46 loc) · 1.69 KB

Templates.md

File metadata and controls

67 lines (46 loc) · 1.69 KB

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:

  1. Constructor:

    new Templates([
        'first' => new Template('First name: %first_name%'),
        'last'  => new Template('Last name: %last_name%'),
    ]);
  2. Static method fromArray(array $templates) - creates and returns the collection from given array

    Templates::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.

More

  1. Base test case (with common methods and data providers)
  2. Collection of elements
  3. Templates
  4. Exceptions
  5. Static methods
    1. Arrays
    2. Regex
  6. Value Objects

‹ Back to Readme