Skip to content

Instantly share code, notes, and snippets.

@avalanche123
Forked from jmikola/fitzify.php
Created July 28, 2010 22:39
Show Gist options
  • Save avalanche123/496590 to your computer and use it in GitHub Desktop.
Save avalanche123/496590 to your computer and use it in GitHub Desktop.
<?php
function fitzify ($input) {
return implode(\PHP_EOL, array_map(function($line) {
return $line . (rand(1, 4) == 1 ? str_repeat("\t", rand(1, 4)) : '');
}, explode(\PHP_EOL, $input)));
}
function fitzify_file($path) {
if ( ! is_file($path)) {
throw new InvalidArgumentException($path . 'doesn\'t appear to be a valid file');
}
if ( ! file_put_contents($path, fitzify(file_get_contents($path)))) {
throw new RuntimeException('Could not fitzify ' . $path . ', check file permissions');
}
}
$a = file_get_contents(__FILE__);
echo fitzify($a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment