From 6a03636f1125c7a99ba2998d5145bcce58cac2e4 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Wed, 8 Jun 2016 21:46:22 -0500 Subject: [PATCH] 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 --- .travis.yml | 2 +- LICENSE | 4 +-- README.md | 2 -- composer.json | 2 +- src/LoremIpsum.php | 62 +++++++++++++++------------------------------- 5 files changed, 24 insertions(+), 48 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9ad6317..8e5f2fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,11 +5,11 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm matrix: allow_failures: - - php: 5.6 - php: hhvm install: diff --git a/LICENSE b/LICENSE index 7c836d4..08533da 100644 --- a/LICENSE +++ b/LICENSE @@ -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 @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index f9dd2c5..a1bc7f7 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/composer.json b/composer.json index f47eea0..9f67f91 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/LoremIpsum.php b/src/LoremIpsum.php index ab32324..95164be 100644 --- a/src/LoremIpsum.php +++ b/src/LoremIpsum.php @@ -9,7 +9,7 @@ * Redistribution of these files must retain the above copyright notice. * * @author Josh Sherman - * @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', $tag, $string); } @@ -400,8 +379,7 @@ class LoremIpsum } } - if (!$array) - { + if (!$array) { $strings = implode($delimiter, $strings); }