Make Predis\ConnectionParameters extensible.

This commit is contained in:
Daniele Alessandri
2011-04-03 09:59:54 +02:00
parent 9d5dc120dc
commit 741495037e
+15
View File
@@ -55,6 +55,21 @@ class ConnectionParameters implements IConnectionParameters {
}
}
public static function define($parameter, $default, $callable = null) {
self::ensureDefaults();
self::$_defaultParameters[$parameter] = $default;
if (!isset($callable)) {
unset(self::$_validators[$parameter]);
return;
}
if (!is_callable($callable)) {
throw new \InvalidArgumentException(
"The validator for $parameter must be a callable object"
);
}
self::$_validators[$parameter] = $callable;
}
private function parseURI($uri) {
if (stripos($uri, 'unix') === 0) {
// Hack to support URIs for UNIX sockets with minimal effort.