for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Monolol\Lolifiers;
use Monolol\Lolifier;
class Tourette implements Lolifier
{
private
$swearWordsProvider;
$swearWordsProvider
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
class A { var $property; }
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.
public function __construct(SwearWordsProvider $swearWordsProvider)
$this->swearWordsProvider = $swearWordsProvider;
}
public function isHandling(array $record)
return true;
public function lolify(array $record)
$messageArray = explode(' ', $record['message']);
$badWords = $this->swearWordsProvider->getSwearWords();
$iterations = rand(1, 3);
for($i = 0; $i < $iterations; $i++)
$badWord = $this->chooseBadWordRandomly($badWords);
$this->insertSwearWordIntoMessage($messageArray, $badWord);
$record['message'] = implode(' ', $messageArray);
return $record;
private function chooseBadWordRandomly(array $badWords)
$index = array_rand($badWords);
return $badWords[$index];
private function insertSwearWordIntoMessage(array &$messageArray, $badWord)
array_splice($messageArray, rand(0, count($messageArray)), 0, $badWord);
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.