-
-
Save avalanche123/496590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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