Skip to content

Commit

Permalink
add some type check
Browse files Browse the repository at this point in the history
  • Loading branch information
Jérémy JOURDIN committed Jan 17, 2014
1 parent 8111050 commit 0ee779f
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/M6Web/Component/RedisMock/RedisMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ public function srem($key, $member)

public function lrem($key, $count, $value)
{
if (!isset($this->data[$key]) || !is_array($this->data[$key])) {
return $this->returnPipedInfo(null);
}

$arr = $this->data[$key];
$reversed = false;

Expand Down Expand Up @@ -293,7 +297,11 @@ public function hmset($key, $pairs)

public function lpush($key)
{
if (isset($this->data[$key]) && !is_array($this->data[$key])) {
if (!isset($this->data[$key])) {
$this->data[$key] = array();
}

if (!is_array($this->data[$key])) {
return $this->returnPipedInfo(null);
}

Expand Down Expand Up @@ -327,6 +335,10 @@ public function rpush($key)

public function ltrim($key, $start, $stop)
{
if (!is_array($this->data[$key])) {
return $this->returnPipedInfo(null);
}

$this->data[$key] = array_slice($this->data[$key], $start, ( $stop > 0 ? $stop - $start : $stop));

return $this->returnPipedInfo('OK');
Expand Down

0 comments on commit 0ee779f

Please sign in to comment.