Move the logic of the connection factory option to a dedicated class.

This commit is contained in:
Daniele Alessandri
2011-04-12 14:41:30 +02:00
parent 1a175da7ca
commit cbc7929f6e
2 changed files with 23 additions and 14 deletions
@@ -0,0 +1,21 @@
<?php
namespace Predis\Options;
use Predis\IConnectionFactory;
use Predis\ConnectionFactory;
class ClientConnectionFactory extends Option {
public function validate($value) {
if ($value instanceof IConnectionFactory) {
return $value;
}
if (is_array($value)) {
return new ConnectionFactory($value);
}
}
public function getDefault() {
return new ConnectionFactory();
}
}