Last active
May 2, 2019 10:44
-
-
Save seebz/aab5a7884f1eda7977c4 to your computer and use it in GitHub Desktop.
moo.php
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 | |
| /* ###################################################################### | |
| Here be cows – but: Never ask, never tell | |
| ##################################################################### */ | |
| abstract class Moo | |
| { | |
| public static function getMooLine($quiet = false) | |
| { | |
| $special = localtime(time(), true); | |
| if ($special['tm_mon'] == 11 && $special['tm_mday'] == 25) | |
| $line = 'PACKAGEMANAGER'; | |
| elseif ($special['tm_mon'] == 7 && $special['tm_mday'] == 16) | |
| $line = 'APPRECIATION'; | |
| elseif ($special['tm_mon'] == 10 && $special['tm_mday'] == 7) | |
| $line = 'AGITATION'; | |
| elseif ($special['tm_mon'] == 1 && $special['tm_mday'] == 18) | |
| $line = 'AIRBORN'; | |
| else | |
| $line = 'NORMAL'; | |
| $out = ''; | |
| if (! $quiet) | |
| $out .= '..."'; | |
| switch($line) { | |
| case 'PACKAGEMANAGER': $out .= "Happy package management day!"; break; | |
| case 'APPRECIATION': $out .= "Three moos for Debian!"; break; | |
| case 'AGITATION': $out .= "Whoever needs milk, bows to the animal."; break; | |
| case 'AIRBORN': $out .= "It's a Bird ... It's a Plane ... It's Super Cow!"; break; | |
| default: $out .= "Have you mooed today?"; break; | |
| } | |
| if (! $quiet) | |
| $out .= '"...'; | |
| return $out; | |
| } | |
| public function printMooLine() | |
| { | |
| print static::getMooLine(); | |
| return true; | |
| } | |
| public static function DoMoo1($quiet = false) | |
| { | |
| if ($quiet) | |
| return static::printMooLine(); | |
| $moo = static::getMooLine(); | |
| $depth = mb_strlen($moo) / 4; | |
| $spaces = static::OutputInDepth($depth, ' '); | |
| echo '' | |
| . $spaces . " (__) \n" | |
| . $spaces . " (oo) \n" | |
| . $spaces . " /------\\/ \n" | |
| . $spaces . " / | || \n" | |
| . $spaces . " * /\\---/\\ \n" | |
| . $spaces . " ~~ ~~ \n" | |
| . $moo; | |
| return true; | |
| } | |
| public static function DoMoo2($quiet = false, $color = false) | |
| { | |
| if ($quiet) | |
| return static::printMooLine(); | |
| $moo = static::getMooLine(); | |
| $depth = mb_strlen($moo) / 4; | |
| $spaces = static::OutputInDepth($depth, ' '); | |
| if (! $color) { | |
| echo '' | |
| . $spaces . " (__) \n" | |
| . $spaces . " _______~(..)~ \n" | |
| . $spaces . " ,----\\(oo) \n" | |
| . $spaces . " /|____|,' \n" | |
| . $spaces . " * /\"\\ /\\ \n" | |
| . $spaces . " ~ ~ ~ ~ \n" | |
| . $moo; | |
| } | |
| else { | |
| echo '' | |
| . $spaces . " \033[1;97m(\033[0;33m__\033[1;97m)\033[0m\n" | |
| . $spaces . " \033[31m_______\033[33m~(\033[1;34m..\033[0;33m)~\033[0m\n" | |
| . $spaces . " \033[33m,----\033[31m\\\033[33m(\033[1;4;35moo\033[0;33m)\033[0m\n" | |
| . $spaces . " \033[33m/|____|,'\033[0m\n" | |
| . $spaces . " \033[1;5;97m*\033[0;33m /\\ /\\\033[0m\n" | |
| . "\033[32m"; | |
| for ($i = mb_strlen($moo) / 2; $i > 1; $i--) | |
| echo "wW"; | |
| echo "w\033[0m\n" . $moo; | |
| } | |
| return true; | |
| } | |
| public static function DoMoo3($quiet = false) | |
| { | |
| if ($quiet) | |
| return static::printMooLine(); | |
| $moo = static::getMooLine(); | |
| $depth = mb_strlen($moo) / 16; // à vérifier ! | |
| $spaces = static::OutputInDepth($depth, ' '); | |
| echo '' | |
| . $spaces . " \\_/ \n" | |
| . $spaces . " m00h (__) -(_)- \n" | |
| . $spaces . " \\ ~Oo~___ / \\\n" | |
| . $spaces . " (..) |\\ \n" | |
| . $spaces . "_________|_|_|__________" | |
| . static::OutputInDepth((mb_strlen($moo) - ($depth + 27)), "_") | |
| . "\n" . $moo; | |
| return true; | |
| } | |
| public static function DoMooApril($quiet = false) | |
| { | |
| if ($quiet) { | |
| echo "Have you smashed some milk today?" . "\n"; | |
| return true; | |
| } | |
| echo '' | |
| . " _ _\n" | |
| . " (_\\___( \\,\n" | |
| . " )___ _ Have you smashed some milk today?\n" | |
| . " /( (_)-(_) /\n" | |
| . " ,---------' \\_\n" | |
| . " //( ',__,' \\ (' ')\n" | |
| . " // ) '----'\n" | |
| . " '' ; \\ .--. ,/\n" | |
| . " | )',_,'----( ;\n" | |
| . " ||| ''' '||\n"; | |
| return true; | |
| } | |
| public static function DoMoo($nb = 1) | |
| { | |
| if (date('m-d') == '04-10') { | |
| return static::DoMooApril(); | |
| } | |
| switch($nb) { | |
| case 1: return static::DoMoo1(); | |
| case 2: return static::DoMoo2(); | |
| case 3: return static::DoMoo3(); | |
| case 4: return static::DoMooApril(); | |
| default: return static::DoMoo1(); | |
| } | |
| } | |
| protected static function OutputInDepth($depth, $separator) | |
| { | |
| if ($depth < 0) | |
| return ''; | |
| return str_repeat($separator, 1 + $depth); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment