public static function patch($source, $dest = null)
{
$source = ltrim($source, '\\');
if (is_object($source) || class_exists($source)) {
$reference = $source;
} else {
$reference = null;
if (MonkeyPatcher::blacklisted($source)) {
throw new Exception("Monkey patching `{$source}()` is not supported by Kahlan.");
}
}
$method = static::$_registered[$source] = new Method(compact('reference'));
if (!$dest) {
return $method;
}
$method->toBe($dest);
return $method;
}