Last active
April 5, 2019 17:17
-
-
Save DaveyJake/75da7aeba3c4f9f47e9b26dc21dd5a16 to your computer and use it in GitHub Desktop.
Matt Hardy Must...
This file contains 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 | |
/** | |
* From the vessel that was this author... | |
* | |
* "Why this is simply... WONDERFUL! I have now entered this vessel known as | |
* 'GEETHUB' and, yes, my reign is now uponeth your precious CODE! We | |
* now begin the FINAL DELETION!" | |
* | |
* From the vessel that is, once again, this author... | |
* | |
* @author Davey Jacobson <djacobson@usarugby.org> | |
* @see {@link https://twitter.com/DaveyJacobson/status/1027305241090244608} | |
* | |
* This function was inspired by the one and only, future WWE Hall of Famer, {@link https://twitter.com/MATTHARDYBRAND|Matt Hardy}. | |
* I'm making this Gist because (1) I actually wrote and implemented this code | |
* in my work's actual live platform and (2) Matt Hardy, HIMSELF, even 'liked' | |
* it! Here's the {@link https://twitter.com/DaveyJacobson/status/1027305241090244608|Tweet}. | |
* | |
* It's used primarily to remove empty values from arrays and/or any value that | |
* equals 'obsolete'. | |
* | |
* @example { | |
* | |
* $are_these_obsolete_mules = array( | |
* 'brother_nero' => 'not_a_mule', | |
* 'dudleys' => 'obsolete', | |
* 'edge_christian' => 'obsolete', | |
* 'king_maxel' => 'the_great_ruler', | |
* 'young_bucks' => 'the_future_awaits', | |
* ); | |
* | |
* $not_obsolete_mules = matt_hardy_must( 'DELETE!', $are_these_obsolete_mules ); | |
* | |
* @return $not_obsolete_mules { | |
* array( | |
* 'brother_nero' => 'not_a_mule', | |
* 'king_maxel' => 'the_great_ruler', | |
* 'young_bucks' => 'the_future_awaits', | |
* ); | |
* } | |
* | |
* } | |
* | |
* @package The_DELETEr_of_Worlds | |
* @subpackage Yesssssssssss | |
* | |
* @version 1.0.0 - Introduced during the World Wrestling Federation's 'Attitude Era.' | |
* @version 2.0.0 - New Version during what many call the era of 'Ruthleeess Aggression.' | |
* @version 3.0.0 - BROKEN with Brother Nero! | |
* @version 3.5.0 - Back home in WWE although not quite 'awake' shall we say? | |
* @version 4.0.0 - Finally WOKEN! Yes... BACK in control of the vessel that was Matt Hardy. | |
* | |
* @param string $i_must What must WOKEN Matt Hardy do in this vessel? | |
* @param array $condeetions What 'condeetions' requires such action? | |
* @return array We are left with NO OBSOLETE MULES! | |
*/ | |
function matt_hardy_must( $i_must = '', $condeetions = array() ) { | |
// When one has no condeetion one can do nothing. | |
if ( empty( $condeetions ) ) | |
{ | |
return; | |
} | |
else | |
{ | |
// A gift from Jericho of Chris, a LEEST for OBSOLETE MULES! | |
$possible_obsolete_mules = array(); | |
// Hear the words of WOKEN! | |
$woken = array( "DELETE!", 'delete', 'mower of lawns', 'lake of reincarnation' ); | |
// THE GREATEST WORD of WOKEN: DELETE! DELETE! DELETE! DELETE! DELETE! | |
$delete = array( "DELETE!", 'DELETE', 'delete!', 'delete' ); | |
// WOKEN words translated for VANGUARD! | |
function _translate_for_vanguard( $woken_word ) | |
{ | |
$vanguard = ''; | |
$delimeter = '_'; | |
if ( empty( $woken_word ) ) | |
{ | |
$vanguard = null; | |
} | |
else | |
{ | |
$patterns = array( | |
"/[ ]+/", | |
"/-/", | |
"/([a-z])(')([a-z])/", | |
'/([a-z])([A-Z])/', | |
'/([a-z])([0-9])/', | |
'/([A-Z!])([0-9])/' | |
); | |
$replacements = array( | |
$delimeter, | |
$delimeter, | |
'$1$3', | |
"$1{$delimeter}$2", | |
"$1{$delimeter}$2", | |
"$1{$delimeter}$2", | |
); | |
$vanguard = strtolower( preg_replace( $patterns, $replacements, $woken_word ) ); | |
} | |
return $vanguard; | |
} | |
// Listen VANGUARD! | |
$listen_vanguard = array_map( '_translate_for_vanguard', $woken ); | |
// Vanguard understands Matt Hardy... | |
$matt_hardy_for_vanguard = _translate_for_vanguard( $i_must ); | |
// Do you speak of the lexicon in the year 3000 A.D? | |
if ( ! in_array( $matt_hardy_for_vanguard, $listen_vanguard ) ) | |
{ | |
try | |
{ | |
throw new Exception( "I do not speak the language of your lexicon!", 3000 ); | |
} | |
catch( Exception $e ) | |
{ | |
echo "{$e->getMessage()} My lexicon is of the year {$e->getCode()} A.D.\n\n"; | |
} | |
// For now we must contend with the OBSOLETE MULES that exist! | |
return $condeetions; | |
} | |
else | |
{ | |
// A list of each lexicon where a new condeetion was gained. | |
foreach ( $condeetions as $lexicon => $condeetion ) | |
{ | |
if ( | |
( empty( $condeetion ) || 'obsolete' === $condeetion ) && | |
in_array( $matt_hardy_for_vanguard, $delete ) | |
) { | |
// DELETE! DELETE! DELETE! DELETE! DELETE! | |
unset( $condeetion ); | |
} | |
elseif ( | |
in_array( $matt_hardy_for_vanguard, $listen_vanguard ) || | |
! in_array( $i_must, $delete ) | |
) { | |
// For now we must contend with the OBSOLETE MULES that exist! | |
$possible_obsolete_mules[ $lexicon ] = $condeetion; | |
} | |
else | |
{ | |
// For now we must contend with the OBSOLETE MULES that exist! | |
$possible_obsolete_mules[ $lexicon ] = $condeetion; | |
} | |
} | |
// Soon you will be placed into the LAKE OF REINCARNATION!!! | |
return $possible_obsolete_mules; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment