mf / stringify
Simple and tiny class (function) to stringify anything in PHP.
Installs: 8 222
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
Requires (Dev)
- lmc/coding-standard: ^3.3
- mf/collections-php: ^8.0
- phpstan/extension-installer: ^1.3.1
- phpstan/phpstan: ^1.10.49
- phpstan/phpstan-phpunit: ^1.3.15
- phpunit/phpunit: ^10.5.3
This package is auto-updated.
Last update: 2024-12-13 11:53:57 UTC
README
Simple and tiny class (function) to stringify anything in PHP.
Installation
composer require mf/stringify
Usage
By class and static method
use MF\Stringify\Stringify; echo Stringify::stringify([1, 2, 3]); // "[1, 2, 3]"
By standalone function
use function MF\Stringify\stringify; echo stringify([1, 2, 3]); // "[1, 2, 3]"
$result = array_map(stringify(...), [1, 'two']); // ['1', '"two"']
Sprintf bonus
with a new
%A
placeholder forstringify
function
use function MF\Stringify\sprintf; echo sprintf('Hello %A!', 'world'); // Hello "world"! echo sprintf('Hello %A!', ['world']); // Hello ["world"]!
Example
NOTE: values longer than 100 chars is shrinked to 100 chars with ...
suffix
For easier examples, let's use a standalone function
Changelog
For latest changes see CHANGELOG.md file. We follow Semantic Versioning.
Contributing and development
Install dependencies
composer install
Run tests
For each pull-request, unit tests as well as static analysis and codestyle checks must pass.
To run all those checks execute:
composer all