Last active
December 12, 2015 03:18
-
-
Save tatat/4705301 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 | |
class Nyan { | |
static public $table = array(); | |
public static function what_should_name_this_method() { | |
$args = func_get_args(); | |
$key = array_shift($args); | |
foreach ($args as $arg) { | |
if (!array_key_exists($arg, self::$table[$key])) | |
return false; | |
} | |
return true; | |
} | |
public static function what_should_name_this_method_any() { | |
$args = func_get_args(); | |
$key = array_shift($args); | |
foreach ($args as $arg) { | |
if (array_key_exists($arg, self::$table[$key])) | |
return true; | |
} | |
return false; | |
} | |
public $key = null; | |
public $class = null; | |
public function __construct($key) { | |
$this->class = get_class($this); | |
$this->key = $key; | |
} | |
public function has() { | |
$args = func_get_args(); | |
array_unshift($args, $this->key); | |
return call_user_func_array(array($this->class, 'what_should_name_this_method'), $args); | |
} | |
public function has_any() { | |
$args = func_get_args(); | |
array_unshift($args, $this->key); | |
return call_user_func_array(array($this->class, 'what_should_name_this_method_any'), $args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment