dcsg/stringy-template

Stringy and String Template together

2.0.0 2022-03-21 12:37 UTC

This package is auto-updated.

Last update: 2024-10-22 16:36:13 UTC


README

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 hi@dcsg.me instead of using the issue tracker.

Credits

License

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