bitandblack / word-wrapper
Wrapping words for a perfect typography
2.3.0
2024-09-04 07:16 UTC
Requires
- php: >=8.2
- bitandblack/helpers: ^1.0 || ^2.0
Requires (Dev)
- phpstan/phpstan: ^1.0
- phpunit/phpunit: ^11.0
- rector/rector: ^1.0
- symfony/var-dumper: ^7.0
- symplify/easy-coding-standard: ^12.0
README
Bit&Black Word Wrapper
Wrapping text for a perfect typography.
Installation
This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/word-wrapper.
Usage
These wrappers are available:
LinesWrapper: This class divides a text to reach a given number of lines.MaxLengthWrapper: This class wraps a text when a lines reaches the maximum length of characters.
These outputs are available:
CSSOutput: This class uses<span>to divide the lines. Eachspanhasclass="word-wrapper-line"which you can use to define a wrap by your own. For examplewhite-space: nowrapis very useful here. It's possible to customize the tag.HTMLOutput: This class uses<br>to wrap into new lines. It's possible to customize the tag.CustomOutput: This class needs to know your custom string. This is the second parameter.
Example
This example makes use of the LinesWrapper and the HTMLOutput.
<?php
use BitAndBlack\WordWrapper\Output\HTMLOutput;
use BitAndBlack\WordWrapper\Wrapper\LinesWrapper;
$sentence = 'The Lord of the Rings';
$wrapper = new LinesWrapper(2, $sentence);
echo new HTMLOutput($wrapper);
This will echo The Lord of <br>the Rings.
Help
If you have questions feel free to contact us under hello@bitandblack.com.
Further information about Bit&Black can be found under www.bitandblack.com.