bitandblack / word-wrapper
Wrapping words for a perfect typography
0.2.0
2020-03-13 10:49 UTC
Requires
- php: ^7.2
- bitandblack/helpers: ^1.1
Requires (Dev)
- phpstan/phpstan: ^0.12.0
- phpunit/phpunit: ^8.0 || ^9.0
This package is auto-updated.
Last update: 2021-01-13 12:41:39 UTC
README
Word Wrapper
Wrapping words 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
This wrappers are available:
LinesWrapper
: This class divides a sentence to reach a given number of lines.MaxLengthWrapper
: This class wraps a sentence when a lines reaches the maximum length of characters.
This outputs are available:
CSSOutput
: This class uses<span>
to divide the lines. Eachspan
hasclass="word-wrapper-line"
which you can use to define a wrap by your own. For examplewhite-space: nowrap
is 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 word-wrapper@bitandblack.com
.