From 8b7d0ab899fea13b57ccdc737fba35b7cd7e2dc6 Mon Sep 17 00:00:00 2001 From: Song Date: Fri, 13 Apr 2018 02:17:23 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/BootExtension.php | 2 +- src/DataType/DataType.php | 14 +++++++++----- src/DataType/Hashes.php | 14 +++++++------- src/DataType/Lists.php | 12 ++++++------ src/DataType/Sets.php | 11 ++++++----- src/DataType/SortedSets.php | 18 +++++++++--------- src/DataType/Strings.php | 10 +++++----- src/RedisController.php | 17 +++++++++-------- src/RedisManager.php | 14 +++++++------- src/RedisManagerServiceProvider.php | 2 +- 10 files changed, 60 insertions(+), 54 deletions(-) diff --git a/src/BootExtension.php b/src/BootExtension.php index 1b2aca3..a351104 100644 --- a/src/BootExtension.php +++ b/src/BootExtension.php @@ -45,4 +45,4 @@ public static function import() parent::createPermission('Redis Manager', 'ext.redis-manager', 'redis*'); } -} \ No newline at end of file +} diff --git a/src/DataType/DataType.php b/src/DataType/DataType.php index 7c461b8..2d397ce 100644 --- a/src/DataType/DataType.php +++ b/src/DataType/DataType.php @@ -33,26 +33,30 @@ public function getConnection() /** * @param string $key + * * @return mixed */ - public abstract function fetch(string $key); + abstract public function fetch(string $key); /** * @param array $params + * * @return mixed */ - public abstract function update(array $params); + abstract public function update(array $params); /** * @param array $params + * * @return mixed */ - public abstract function store(array $params); + abstract public function store(array $params); /** * Returns the remaining time to live of a key that has a timeout. * * @param string $key + * * @return int */ public function ttl($key) @@ -64,7 +68,7 @@ public function ttl($key) * Set a timeout on key. * * @param string $key - * @param integer $expire + * @param int $expire * * @return void */ @@ -82,4 +86,4 @@ public function setTtl($key, $expire) $this->getConnection()->persist($key); } } -} \ No newline at end of file +} diff --git a/src/DataType/Hashes.php b/src/DataType/Hashes.php index f49820e..61f4901 100644 --- a/src/DataType/Hashes.php +++ b/src/DataType/Hashes.php @@ -20,7 +20,6 @@ public function update(array $params) $key = array_get($params, 'key'); if (array_has($params, 'field')) { - $field = array_get($params, 'field'); $value = array_get($params, 'value'); @@ -40,10 +39,10 @@ public function update(array $params) */ public function store(array $params) { - $key = array_get($params, 'key'); - $ttl = array_get($params, 'ttl'); - $field = array_get($params, 'field'); - $value = array_get($params, 'value'); + $key = array_get($params, 'key'); + $ttl = array_get($params, 'ttl'); + $field = array_get($params, 'field'); + $value = array_get($params, 'value'); $this->getConnection()->hset($key, $field, $value); @@ -61,13 +60,14 @@ public function store(array $params) * Remove a field from a hash. * * @param array $params + * * @return int */ public function remove(array $params) { - $key = array_get($params, 'key'); + $key = array_get($params, 'key'); $field = array_get($params, 'field'); return $this->getConnection()->hdel($key, [$field]); } -} \ No newline at end of file +} diff --git a/src/DataType/Lists.php b/src/DataType/Lists.php index c0197be..f201dfe 100644 --- a/src/DataType/Lists.php +++ b/src/DataType/Lists.php @@ -20,7 +20,6 @@ public function update(array $params) $key = array_get($params, 'key'); if (array_has($params, 'push')) { - $item = array_get($params, 'item'); $command = $params['push'] == 'left' ? 'lpush' : 'rpush'; @@ -40,9 +39,9 @@ public function update(array $params) */ public function store(array $params) { - $key = array_get($params, 'key'); - $item = array_get($params, 'item'); - $ttl = array_get($params, 'ttl'); + $key = array_get($params, 'key'); + $item = array_get($params, 'item'); + $ttl = array_get($params, 'ttl'); $this->getConnection()->rpush($key, [$item]); @@ -60,11 +59,12 @@ public function store(array $params) * Remove a member from list by index. * * @param array $params + * * @return mixed */ public function remove(array $params) { - $key = array_get($params, 'key'); + $key = array_get($params, 'key'); $index = array_get($params, 'index'); $lua = <<<'LUA' @@ -74,4 +74,4 @@ public function remove(array $params) return $this->getConnection()->eval($lua, 1, $key, $index); } -} \ No newline at end of file +} diff --git a/src/DataType/Sets.php b/src/DataType/Sets.php index 92c9667..a2dcfe0 100644 --- a/src/DataType/Sets.php +++ b/src/DataType/Sets.php @@ -40,9 +40,9 @@ public function update(array $params) */ public function store(array $params) { - $key = array_get($params, 'key'); - $ttl = array_get($params, 'ttl'); - $members = array_get($params, 'members'); + $key = array_get($params, 'key'); + $ttl = array_get($params, 'ttl'); + $members = array_get($params, 'members'); $this->getConnection()->sadd($key, $members); @@ -60,13 +60,14 @@ public function store(array $params) * Remove a member from a set. * * @param array $params + * * @return int */ public function remove(array $params) { - $key = array_get($params, 'key'); + $key = array_get($params, 'key'); $member = array_get($params, 'member'); return $this->getConnection()->srem($key, $member); } -} \ No newline at end of file +} diff --git a/src/DataType/SortedSets.php b/src/DataType/SortedSets.php index 2a709fd..e4ff3a4 100644 --- a/src/DataType/SortedSets.php +++ b/src/DataType/SortedSets.php @@ -9,7 +9,7 @@ class SortedSets extends DataType */ public function fetch(string $key) { - return $this->getConnection()->zrange($key,0, -1, ['WITHSCORES' => true]); + return $this->getConnection()->zrange($key, 0, -1, ['WITHSCORES' => true]); } public function update(array $params) @@ -23,8 +23,7 @@ public function update(array $params) } if (array_has($params, '_editable')) { - - $score = array_get($params, 'value'); + $score = array_get($params, 'value'); $member = array_get($params, 'pk'); $this->getConnection()->zadd($key, [$member => $score]); @@ -36,10 +35,10 @@ public function update(array $params) */ public function store(array $params) { - $key = array_get($params, 'key'); - $ttl = array_get($params, 'ttl'); - $score = array_get($params, 'score'); - $member = array_get($params, 'member'); + $key = array_get($params, 'key'); + $ttl = array_get($params, 'ttl'); + $score = array_get($params, 'score'); + $member = array_get($params, 'member'); $this->getConnection()->zadd($key, [$member => $score]); @@ -57,13 +56,14 @@ public function store(array $params) * Remove a member from a sorted set. * * @param array $params + * * @return int */ public function remove(array $params) { - $key = array_get($params, 'key'); + $key = array_get($params, 'key'); $member = array_get($params, 'member'); return $this->getConnection()->zrem($key, $member); } -} \ No newline at end of file +} diff --git a/src/DataType/Strings.php b/src/DataType/Strings.php index 85d9770..3b53719 100644 --- a/src/DataType/Strings.php +++ b/src/DataType/Strings.php @@ -25,9 +25,9 @@ public function update(array $params) */ public function store(array $params) { - $key = array_get($params, 'key'); - $value = array_get($params, 'value'); - $ttl = array_get($params, 'ttl'); + $key = array_get($params, 'key'); + $value = array_get($params, 'value'); + $ttl = array_get($params, 'ttl'); $this->getConnection()->set($key, $value); @@ -36,7 +36,7 @@ public function store(array $params) } return redirect(route('redis-index', [ - 'conn' => request('conn') + 'conn' => request('conn'), ])); } -} \ No newline at end of file +} diff --git a/src/RedisController.php b/src/RedisController.php index 83b6777..70e72e3 100644 --- a/src/RedisController.php +++ b/src/RedisController.php @@ -11,14 +11,13 @@ class RedisController extends BaseController { /** - * Index page + * Index page. * * @return Content */ public function index() { return Admin::content(function (Content $content) { - $content->header('Redis manager'); $content->description('Connections'); $content->breadcrumb(['text' => 'Redis manager']); @@ -51,7 +50,6 @@ public function index() public function edit(Request $request) { return Admin::content(function (Content $content) use ($request) { - $connection = $request->get('conn', 'default'); $manager = $this->manager(); @@ -80,15 +78,15 @@ public function edit(Request $request) } /** - * Create page + * Create page. * * @param Request $request + * * @return Content */ public function create(Request $request) { return Admin::content(function (Content $content) use ($request) { - $connection = $request->get('conn', 'default'); $manager = $this->manager(); @@ -136,6 +134,7 @@ public function destroy(Request $request) /** * @param Request $request + * * @return array */ public function fetch(Request $request) @@ -145,6 +144,7 @@ public function fetch(Request $request) /** * @param Request $request + * * @return mixed */ public function remove(Request $request) @@ -156,6 +156,7 @@ public function remove(Request $request) /** * @param Request $request + * * @return mixed */ public function update(Request $request) @@ -173,7 +174,6 @@ public function update(Request $request) public function console(Request $request) { return Admin::content(function (Content $content) use ($request) { - $connection = $request->get('conn', 'default'); $manager = $this->manager(); @@ -197,7 +197,7 @@ public function console(Request $request) } /** - * Execute a redis command + * Execute a redis command. * * @param Request $request * @@ -224,6 +224,7 @@ public function execute(Request $request) * Render exception. * * @param \Exception $exception + * * @return string */ protected function renderException(\Exception $exception) @@ -265,4 +266,4 @@ protected function manager() return RedisManager::instance($conn); } -} \ No newline at end of file +} diff --git a/src/RedisManager.php b/src/RedisManager.php index 8e08d6a..d018967 100644 --- a/src/RedisManager.php +++ b/src/RedisManager.php @@ -17,8 +17,7 @@ use Predis\Pipeline\Pipeline; /** - * Class RedisManager - * @package Encore\Admin\RedisManager + * Class RedisManager. */ class RedisManager extends Extension { @@ -164,7 +163,7 @@ public function getInformation() * Scan keys in redis by giving pattern. * * @param string $pattern - * @param int $count + * @param int $count * * @return array|\Predis\Pipeline\Pipeline */ @@ -214,7 +213,7 @@ public function fetch($key) $class = $this->{$type}(); $value = $class->fetch($key); - $ttl = $class->ttl($key); + $ttl = $class->ttl($key); return compact('key', 'value', 'ttl', 'type'); } @@ -228,7 +227,7 @@ public function fetch($key) */ public function update(Request $request) { - $key = $request->get('key'); + $key = $request->get('key'); $type = $request->get('type'); /** @var DataType $class */ @@ -256,9 +255,10 @@ public function del($key) } /** - * 运行redis命令 + * 运行redis命令. * * @param string $command + * * @return mixed */ public function execute($command) @@ -267,4 +267,4 @@ public function execute($command) return $this->getConnection()->executeRaw($command); } -} \ No newline at end of file +} diff --git a/src/RedisManagerServiceProvider.php b/src/RedisManagerServiceProvider.php index 03c1a1c..437ce2f 100644 --- a/src/RedisManagerServiceProvider.php +++ b/src/RedisManagerServiceProvider.php @@ -15,4 +15,4 @@ public function boot() RedisManager::boot(); } -} \ No newline at end of file +}