diolan12 / php-lipsum
PHP Lorem Ipsum generator
1.0.0
2023-06-03 07:44 UTC
Requires (Dev)
- phpunit/phpunit: 9.5
README
PHP Lorem Ipsum generator
Github diolan12/php-lipsum
Packagist diolan12/php-lipsum
Installation
composer require diolan12/php-lipsum
Usage
Class Instantiation
use Diolan12\LoremIpsum; $lipsum = new LoremIpsum();
or without use
import
$lipsum = new \Diolan12\LoremIpsum();
instantiation via static method
use Diolan12\LoremIpsum; $lipsum = LoremIpsum::instance();
or without use
import
$lipsum = \Diolan12\LoremIpsum::instance();
Words generation
This method has default value of int 2
use Diolan12\LoremIpsum; $lipsum = LoremIpsum::instance(); echo $lipsum->words()."\n"; echo $lipsum->words(5);
produce:
Lorem ipsum
Lorem ipsum dolor sit amet,
Sentences generation
This method has default value of int 1
use Diolan12\LoremIpsum; $lipsum = LoremIpsum::instance(); echo $lipsum->sentences()."\n\n"; echo $lipsum->sentences(2);
produce:
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
lit. Maecenas mollis vehicula urna, ac dictum turpis vulputate rutrum.
Paragraphs generation
This method has default value of int 1
use Diolan12\LoremIpsum; $lipsum = LoremIpsum::instance(); echo $lipsum->paragraphs();
produce:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas mollis vehicula urna, ac dictum turpis vulputate rutrum. Nulla pharetra massa ligula, a malesuada nibh vehicula nec. Morbi rhoncus sagittis accumsan. Nulla lacinia ex a vehicula cursus. Nunc pulvinar finibus pulvinar. Maecenas eleifend ut sapien a pellentesque. Vestibulum justo purus, tristique quis enim et, dignissim volutpat arcu. Aliquam erat volutpat. In hac habitasse platea dictumst. Nulla et malesuada turpis, ac finibus enim. Fusce non arcu ut est imperdiet mollis. Mauris ultrices purus a tortor consequat rhoncus. Sed eu lacus ac odio fermentum ullamcorper ac rutrum ipsum. Vestibulum lobortis dolor pretium aliquet mollis. Curabitur euismod ante commodo neque ornare, in semper nunc gravida. Ut pretium tellus pulvinar dolor lacinia, vel pretium lacus dictum.
Using Wrapper
We recommend you to use static method instantiation on the class generation. The wrap method has default <p>
tag value, returning the class instance of Diolan12\LoremIpsum
use Diolan12\LoremIpsum; echo LoremIpsum::instance()->wrap()->words(3)."\n"; echo LoremIpsum::instance()->wrap('span')->words(3);
<p>Lorem ipsum dolor</p>
<span>Lorem ipsum dolor</span>
Wrapper method can be use on all method words()
, sentences()
, and paragraphs()
Here is example when using wrapper with single instance of the class.
use Diolan12\LoremIpsum; $lipsum = LoremIpsum::instance(); echo $lipsum->words()."\n"; $lipsum->wrap(); // set wrapper with default tag <p> echo $lipsum->words()."\n"; $lipsum->wrap(null); // disable wrapper with null value echo $lipsum->words()."\n"; $lipsum->wrap('span'); // set wrapper with <span> echo $lipsum->words()."\n";
Lorem ipsum
<p>Lorem ipsum</p>
<span>Lorem ipsum</span>
Dev Test
./vendor/bin/phpunit tests