glhd / ansipants
0.0.2
2024-04-18 19:03 UTC
Requires
- ext-json: *
- illuminate/support: ^10.17|^11|dev-master
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.34
- mockery/mockery: ^1.6
- orchestra/testbench: ^8|^9|10.x-dev|dev-master
- phpunit/phpunit: ^10.5
README
ANSI Pants 👖💫
Installation
composer require glhd/ansipants
Usage
You can instantiate a new ANSI string using the ansi()
helper, with new AnsiString()
,
or with AnsiString::make()
. All string manipulation functions can be chained, just like
the Laravel Stringable
class. Where appropriate, you can pass an additional ignore_style: true
argument into a function to make that function ignore the ANSI styles that are applied
(like color or font style).
An example:
ansi("\e[1mHello💥 \e[3mwo\e[0mrld") ->append(" 🥸🥸🥸") ->padLeft(100) ->wordwrap();
Stringable Macro
You can also create an ANSI string from any Stringable
object:
Str::of("\e[1mHello💥 \e[3mwo\e[0mrld")->ansi(); // Or str("\e[1mHello💥 \e[3mwo\e[0mrld")->ansi();