Skip to content

Stringy and StringTemplate together in one class for simplicity

License

Notifications You must be signed in to change notification settings

dcsg/stringy-template

Repository files navigation

StringyTemplate

Minimum PHP Version Latest Stable Version License Build Status StyleCI SymfonyInsight Quality Gate Status Coverage Vulnerabilities Bugs Security Rating Total Downloads

This Library provides a unified S Class that "glues" two amazing libraries. It integrates the Stringy library created by Daniel St. Jules and the StringTemplate Library create by Nicolò Martini. The Stringy Library is a string manipulation library, while the String Template is an engine to render string templates.

This Library was created because in my projects I've been using both libraries and always ended up in having them integrated into a single class to make it's usage simpler.

Install

Via Composer

$ composer require dcsg/stringy-template

Usage

For the full list of features of Stringy see it's documentation, for more details on the String Template you can also check their documentation.

echo S::render(
    'Hello, my name is {firstName} {lastName}.',
    ['firstName' => 'Daniel', 'lastName' => 'Gomes']
); 
// "Hello, my name is Daniel Gomes."


// Using conversion specifications from `sprintf`
echo S::render(
    'I have {num%.1f} {fruit}.',
    ['num' => 1.5345, 'fruit' => 'oranges']
);
// "I have 1.5 oranges."

echo S::join(['one', 'two', 'three'], ', ');
// "one, two, three"

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE OF CONDUCT for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.