Convert monolithic one-file-lib to a proper PSR-0 file tree

This commit is contained in:
Jordi Boggiano
2011-02-21 03:15:49 +01:00
parent 2a78142b28
commit 30f908cd85
183 changed files with 4189 additions and 3385 deletions
@@ -0,0 +1,36 @@
<?php
namespace Predis\Network;
use Predis\ConnectionParameters;
use Predis\CommunicationException;
class UnixDomainSocketConnection extends TcpConnection {
protected function checkParameters(ConnectionParameters $parameters) {
if ($parameters->scheme != 'unix') {
throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}");
}
$pathToSocket = $parameters->path;
if (!isset($pathToSocket)) {
throw new \InvalidArgumentException('Missing UNIX domain socket path');
}
if (!file_exists($pathToSocket)) {
throw new \InvalidArgumentException("Could not find $pathToSocket");
}
return $parameters;
}
protected function createResource() {
$uri = sprintf('unix:///%s', $this->_params->path);
$connectFlags = STREAM_CLIENT_CONNECT;
if ($this->_params->connection_persistent) {
$connectFlags |= STREAM_CLIENT_PERSISTENT;
}
$this->_socket = @stream_socket_client(
$uri, $errno, $errstr, $this->_params->connection_timeout, $connectFlags
);
if (!$this->_socket) {
$this->onCommunicationException(trim($errstr), $errno);
}
}
}