Updated a bunch of shit

Updated PHP versions to test against, copyright dates, dropped gittip,
cleaned up a bit of formatting to make more PSR-compliant and bumped the
version number slightly
This commit is contained in:
Josh Sherman 2016-06-08 21:46:22 -05:00
parent ece0a6f057
commit 6a03636f11
5 changed files with 24 additions and 48 deletions

View file

@ -5,11 +5,11 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
matrix:
allow_failures:
- php: 5.6
- php: hhvm
install:

View file

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014 Josh Sherman
Copyright (c) 2014, 2015, 2016 Josh Sherman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View file

@ -3,12 +3,10 @@
[![Build Status](http://img.shields.io/travis/joshtronic/php-loremipsum.svg?style=flat)][travis]
[![Coverage Status](http://img.shields.io/coveralls/joshtronic/php-loremipsum.svg?style=flat)][coveralls]
[![Downloads](http://img.shields.io/packagist/dt/joshtronic/php-loremipsum.svg?style=flat)][packagist]
[![Gittip](http://img.shields.io/gittip/joshtronic.svg?style=flat)][gittip]
[travis]: http://travis-ci.org/joshtronic/php-loremipsum
[coveralls]: https://coveralls.io/r/joshtronic/php-loremipsum
[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.

View file

@ -1,7 +1,7 @@
{
"name": "joshtronic/php-loremipsum",
"description": "Lorem ipsum generator in PHP without dependencies",
"version": "1.0.0",
"version": "1.0.1",
"type": "library",
"keywords": ["lorem", "ipsum", "generator"],
"homepage": "https://github.com/joshtronic/php-loremipsum",

View file

@ -9,7 +9,7 @@
* Redistribution of these files must retain the above copyright notice.
*
* @author Josh Sherman <josh@gravityblvd.com>
* @copyright Copyright 2014, Josh Sherman
* @copyright Copyright 2014, 2015, 2016 Josh Sherman
* @license http://www.opensource.org/licenses/mit-license.html
* @link https://github.com/joshtronic/php-loremipsum
*/
@ -135,18 +135,15 @@ class LoremIpsum
// Shuffles and appends the word list to compensate for count
// arguments that exceed the size of our vocabulary list
while ($word_count < $count)
{
while ($word_count < $count) {
$shuffle = true;
while ($shuffle)
{
while ($shuffle) {
$this->shuffle();
// Checks that the last word of the list and the first word of
// the list that's about to be appended are not the same
if (!$word_count || $words[$word_count - 1] != $this->words[0])
{
if (!$word_count || $words[$word_count - 1] != $this->words[0]) {
$words = array_merge($words, $this->words);
$word_count = count($words);
$shuffle = false;
@ -203,8 +200,7 @@ class LoremIpsum
{
$sentences = array();
for ($i = 0; $i < $count; $i++)
{
for ($i = 0; $i < $count; $i++) {
$sentences[] = $this->wordsArray($this->gauss(24.46, 5.08));
}
@ -257,8 +253,7 @@ class LoremIpsum
{
$paragraphs = array();
for ($i = 0; $i < $count; $i++)
{
for ($i = 0; $i < $count; $i++) {
$paragraphs[] = $this->sentences($this->gauss(5.8, 1.93));
}
@ -297,8 +292,7 @@ class LoremIpsum
*/
private function shuffle()
{
if ($this->first)
{
if ($this->first) {
$this->first = array_slice($this->words, 0, 8);
$this->words = array_slice($this->words, 8);
@ -307,9 +301,7 @@ class LoremIpsum
$this->words = $this->first + $this->words;
$this->first = false;
}
else
{
} else {
shuffle($this->words);
}
}
@ -326,23 +318,19 @@ class LoremIpsum
*/
private function punctuate(&$sentences)
{
foreach ($sentences as $key => $sentence)
{
foreach ($sentences as $key => $sentence) {
$words = count($sentence);
// Only worry about commas on sentences longer than 4 words
if ($words > 4)
{
if ($words > 4) {
$mean = log($words, 6);
$std_dev = $mean / 6;
$commas = round($this->gauss($mean, $std_dev));
for ($i = 1; $i <= $commas; $i++)
{
for ($i = 1; $i <= $commas; $i++) {
$word = round($i * $words / ($commas + 1));
if ($word < ($words - 1) && $word > 0)
{
if ($word < ($words - 1) && $word > 0) {
$sentence[$word] .= ',';
}
}
@ -369,29 +357,20 @@ class LoremIpsum
*/
private function output($strings, $tags, $array, $delimiter = ' ')
{
if ($tags)
{
if (!is_array($tags))
{
if ($tags) {
if (!is_array($tags)) {
$tags = array($tags);
}
else
{
} else {
// Flips the array so we can work from the inside out
$tags = array_reverse($tags);
}
foreach ($strings as $key => $string)
{
foreach ($tags as $tag)
{
foreach ($strings as $key => $string) {
foreach ($tags as $tag) {
// Detects / applies back reference
if ($tag[0] == '<')
{
if ($tag[0] == '<') {
$string = str_replace('$1', $string, $tag);
}
else
{
} else {
$string = sprintf('<%1$s>%2$s</%1$s>', $tag, $string);
}
@ -400,8 +379,7 @@ class LoremIpsum
}
}
if (!$array)
{
if (!$array) {
$strings = implode($delimiter, $strings);
}