dcsg / stringy-template
Stringy and String Template together
Requires
- php: ^7.2|^7.4|^8.0|^8.1
- danielstjules/stringy: ^3.1
- nicmart/string-template: ^0.1.1
Requires (Dev)
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-10-22 16:36:13 UTC
README
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.