Implemented PHP-CS-Fixer support

This commit is contained in:
ErickSkrauch
2018-04-17 23:47:25 +03:00
parent bfdcaf2233
commit 02ea7346a8
115 changed files with 883 additions and 363 deletions

View File

@@ -157,7 +157,7 @@ class Connection extends Component implements ConnectionInterface {
/**
* @var array List of available redis commands http://redis.io/commands
*/
const REDIS_COMMANDS = [
public const REDIS_COMMANDS = [
'BLPOP', // key [key ...] timeout Remove and get the first element in a list, or block until one is available
'BRPOP', // key [key ...] timeout Remove and get the last element in a list, or block until one is available
'BRPOPLPUSH', // source destination timeout Pop a value from a list, push it to another list and return it; or block until one is available
@@ -368,14 +368,6 @@ class Connection extends Component implements ConnectionInterface {
*/
private $_client;
public function getConnection() : ClientInterface {
if ($this->_client === null) {
$this->_client = new Client($this->prepareParams(), $this->options);
}
return $this->_client;
}
public function __call($name, $params) {
$redisCommand = mb_strtoupper($name);
if (in_array($redisCommand, self::REDIS_COMMANDS)) {
@@ -385,6 +377,14 @@ class Connection extends Component implements ConnectionInterface {
return parent::__call($name, $params);
}
public function getConnection(): ClientInterface {
if ($this->_client === null) {
$this->_client = new Client($this->prepareParams(), $this->options);
}
return $this->_client;
}
public function executeCommand(string $name, array $params = []) {
return $this->getConnection()->$name(...$params);
}

View File

@@ -30,11 +30,13 @@ class Key {
public function setValue($value): self {
$this->getRedis()->set($this->key, $value);
return $this;
}
public function delete(): self {
$this->getRedis()->del([$this->getKey()]);
return $this;
}
@@ -44,17 +46,19 @@ class Key {
public function expire(int $ttl): self {
$this->getRedis()->expire($this->key, $ttl);
return $this;
}
public function expireAt(int $unixTimestamp): self {
$this->getRedis()->expireat($this->key, $unixTimestamp);
return $this;
}
private function buildKey(array $parts): string {
$keyParts = [];
foreach($parts as $part) {
foreach ($parts as $part) {
$keyParts[] = str_replace('_', ':', $part);
}

View File

@@ -8,11 +8,13 @@ class Set extends Key implements IteratorAggregate {
public function add($value): self {
$this->getRedis()->sadd($this->getKey(), $value);
return $this;
}
public function remove($value): self {
$this->getRedis()->srem($this->getKey(), $value);
return $this;
}