Code cleanup
Converted tabs to spaces, dropped closing ?> and reformatted README to 80 columns.
This commit is contained in:
parent
68e162388d
commit
966f2d26bc
3 changed files with 487 additions and 465 deletions
44
README.md
44
README.md
|
@ -10,19 +10,36 @@
|
|||
[packagist]: https://packagist.org/packages/joshtronic/php-loremipsum
|
||||
[gittip]: https://www.gittip.com/joshtronic/
|
||||
|
||||
Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+ as well as HHVM.
|
||||
Lorem ipsum generator in PHP without dependencies. Compatible with PHP 5.3+ as
|
||||
well as HHVM.
|
||||
|
||||
## Origins
|
||||
|
||||
Once upon a time, I was attempting to find a lorem ipsum generator over on [Packagist](https://packagist.org/search/?q=lorem%20ipsum). I was presented with many options, and some of those options were good. Unfortunately, the bulk of those options depended on Symphony or the Zend Framework. This wouldn’t have been a big deal but under the circumstances, I wanted something that was not tightly coupled to these frameworks because I wanted to use the generator in my _own_ framework.
|
||||
Once upon a time, I was attempting to find a lorem ipsum generator over on
|
||||
[Packagist](https://packagist.org/search/?q=lorem%20ipsum). I was presented
|
||||
with many options, and some of those options were good. Unfortunately, the
|
||||
bulk of those options depended on Symphony or the Zend Framework. This
|
||||
wouldn’t have been a big deal but under the circumstances, I wanted something
|
||||
that was not tightly coupled to these frameworks because I wanted to use the
|
||||
generator in my _own_ framework.
|
||||
|
||||
I had decided to use [badcow/lorem-ipsum](https://packagist.org/packages/badcow/lorem-ipsum) because it did not have any dependencies nor did it rely on any external APIs. As I started to use the library, I found that I was going to have to fight with it to get it to do what I wanted. After digging through the code, I realized that I was going to end up gutting most of it to bend it to my will. I know when you overhaul someone’s code the liklihood of them accepting a pull request goes down dramatically, hence building this library while taking cues from it’s predecessor.
|
||||
I had decided to use
|
||||
[badcow/lorem-ipsum](https://packagist.org/packages/badcow/lorem-ipsum)
|
||||
because it did not have any dependencies nor did it rely on any external APIs.
|
||||
As I started to use the library, I found that I was going to have to fight
|
||||
with it to get it to do what I wanted. After digging through the code, I
|
||||
realized that I was going to end up gutting most of it to bend it to my will.
|
||||
I know when you overhaul someone’s code the liklihood of them accepting a pull
|
||||
request goes down dramatically, hence building this library while taking cues
|
||||
from it’s predecessor.
|
||||
|
||||
Also, the aforementioned package had a bunch of “setter” and “getter” methods that were grossing me out :P
|
||||
Also, the aforementioned package had a bunch of “setter” and “getter” methods
|
||||
that were grossing me out :P
|
||||
|
||||
## Installation
|
||||
|
||||
The preferred installation method is via `composer`. First add the following to your `composer.json`
|
||||
The preferred installation method is via `composer`. First add the following
|
||||
to your `composer.json`
|
||||
|
||||
```json
|
||||
"require": {
|
||||
|
@ -64,7 +81,8 @@ echo '5 paragraphs: ' . $lipsum->paragraphs(5);
|
|||
|
||||
### Wrapping text with HTML tags
|
||||
|
||||
If you would like to wrap the generated text with a tag, pass it as the second parameter:
|
||||
If you would like to wrap the generated text with a tag, pass it as the second
|
||||
parameter:
|
||||
|
||||
```php
|
||||
echo $lipsum->paragraphs(3, 'p');
|
||||
|
@ -77,7 +95,7 @@ Multiple tags can also be specified:
|
|||
```php
|
||||
echo $lipsum->sentences(3, ['article', 'p']);
|
||||
|
||||
// Generptes: <article><p>...</p></article><article><p>...</p></article><article><p>...</p></article>
|
||||
// Generates: <article><p>...</p></article><article><p>...</p></article><article><p>...</p></article>
|
||||
```
|
||||
|
||||
And you can back reference using `$1`:
|
||||
|
@ -106,10 +124,16 @@ print_r($lipsum->wordsArray(5), 'li');
|
|||
|
||||
## Assumptions
|
||||
|
||||
Instead of having an option as to whether or not a string should start the generated output with “Lorem ipsum dolor sit amet, consectetur adipiscing elit.” a few assumptions are baked in. The first string generated will always start with the traditional “Lorem ipsum…”. Subsequent strings may contain those words but will not explicitly start with them.
|
||||
Instead of having an option as to whether or not a string should start the
|
||||
generated output with “Lorem ipsum dolor sit amet, consectetur adipiscing
|
||||
elit.” a few assumptions are baked in. The first string generated will always
|
||||
start with the traditional “Lorem ipsum…”. Subsequent strings may contain
|
||||
those words but will not explicitly start with them.
|
||||
|
||||
## Contributing
|
||||
|
||||
Suggestions and bug reports are always welcome, but karma points are earned for pull requests.
|
||||
Suggestions and bug reports are always welcome, but karma points are earned
|
||||
for pull requests.
|
||||
|
||||
Unit tests are required for all contributions. You can run the test suite from the `tests` directory simply by running `phpunit .`
|
||||
Unit tests are required for all contributions. You can run the test suite
|
||||
from the `tests` directory simply by running `phpunit .`
|
||||
|
|
|
@ -409,4 +409,3 @@ class LoremIpsum
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -125,4 +125,3 @@ class LoremIpsumTest extends PHPUnit_Framework_TestCase
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue