Skip to content

Instantly share code, notes, and snippets.

@pmjones
Created August 9, 2012 17:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pmjones/3306415 to your computer and use it in GitHub Desktop.
Save pmjones/3306415 to your computer and use it in GitHub Desktop.
public function value(&$value, $method, $name)
{
// get the params
$params = func_get_args();
array_shift($params); // $value
array_shift($params); // $method
array_shift($params); // $name
// set up the field name and data
$field = 'field';
$data = (object) [$field => $value];
// prep the rule object
$rule = $this->rule_locator->get($name);
$rule->prep($data, $field);
$passed = call_user_func_array([$rule, $method], $params);
// retain the value and return the pass/fail result
$value = $rule->getValue();
return $passed;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment