Skip to content

Instantly share code, notes, and snippets.

@tatat
Last active December 12, 2015 03:18
Show Gist options
  • Save tatat/4705301 to your computer and use it in GitHub Desktop.
Save tatat/4705301 to your computer and use it in GitHub Desktop.
<?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