Skip to content

Commit

Permalink
Merge pull request #1 from laravel-admin-extensions/analysis-Xar4a0
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
z-song authored Apr 13, 2018
2 parents bac830c + 8b7d0ab commit 0d2449f
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 54 deletions.
2 changes: 1 addition & 1 deletion src/BootExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ public static function import()

parent::createPermission('Redis Manager', 'ext.redis-manager', 'redis*');
}
}
}
14 changes: 9 additions & 5 deletions src/DataType/DataType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -64,7 +68,7 @@ public function ttl($key)
* Set a timeout on key.
*
* @param string $key
* @param integer $expire
* @param int $expire
*
* @return void
*/
Expand All @@ -82,4 +86,4 @@ public function setTtl($key, $expire)
$this->getConnection()->persist($key);
}
}
}
}
14 changes: 7 additions & 7 deletions src/DataType/Hashes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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);

Expand All @@ -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]);
}
}
}
12 changes: 6 additions & 6 deletions src/DataType/Lists.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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]);

Expand All @@ -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'
Expand All @@ -74,4 +74,4 @@ public function remove(array $params)

return $this->getConnection()->eval($lua, 1, $key, $index);
}
}
}
11 changes: 6 additions & 5 deletions src/DataType/Sets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
}
}
}
18 changes: 9 additions & 9 deletions src/DataType/SortedSets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]);
Expand All @@ -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]);

Expand All @@ -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);
}
}
}
10 changes: 5 additions & 5 deletions src/DataType/Strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -36,7 +36,7 @@ public function store(array $params)
}

return redirect(route('redis-index', [
'conn' => request('conn')
'conn' => request('conn'),
]));
}
}
}
17 changes: 9 additions & 8 deletions src/RedisController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -136,6 +134,7 @@ public function destroy(Request $request)

/**
* @param Request $request
*
* @return array
*/
public function fetch(Request $request)
Expand All @@ -145,6 +144,7 @@ public function fetch(Request $request)

/**
* @param Request $request
*
* @return mixed
*/
public function remove(Request $request)
Expand All @@ -156,6 +156,7 @@ public function remove(Request $request)

/**
* @param Request $request
*
* @return mixed
*/
public function update(Request $request)
Expand All @@ -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();
Expand All @@ -197,7 +197,7 @@ public function console(Request $request)
}

/**
* Execute a redis command
* Execute a redis command.
*
* @param Request $request
*
Expand All @@ -224,6 +224,7 @@ public function execute(Request $request)
* Render exception.
*
* @param \Exception $exception
*
* @return string
*/
protected function renderException(\Exception $exception)
Expand Down Expand Up @@ -265,4 +266,4 @@ protected function manager()

return RedisManager::instance($conn);
}
}
}
Loading

0 comments on commit 0d2449f

Please sign in to comment.