Skip to content

Commit

Permalink
"Improve code readability with better structuring
Browse files Browse the repository at this point in the history
This commit involves cleanup and improved structuring of multiple function calls and if-else conditions across multiple classes for improved readability. Code has been refactored to use explicit comparisons, multi-line function arguments and chained method calls to enhance understanding and maintainability.

No changes in functionality have been introduced."
  • Loading branch information
AuroraYolo committed Aug 28, 2023
1 parent 4f9f21e commit c7b34ab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cloud-admin/RedLock/Redis.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
declare(strict_types=1);

declare(strict_types=1);
/**
* This file is part of Cloud-Admin project.
*
* @link https://www.cloud-admin.jayjay.cn
* @document https://wiki.cloud-admin.jayjay.cn
* @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE
*/

namespace CloudAdmin\RedLock;

use CloudAdmin\RedLock\Exceptions\UnknownSetNexException;
Expand All @@ -24,7 +25,7 @@ public function __construct(public string $pool = 'default')
{
}

public function setNex(string $key, string $value, int $expireSeconds) : bool
public function setNex(string $key, string $value, int $expireSeconds): bool
{
if ($key === '' || $value === '') {
throw new UnknownSetNexException("redis SET keyNX or value can't be empty");
Expand All @@ -37,19 +38,19 @@ public function setNex(string $key, string $value, int $expireSeconds) : bool
['nx', 'ex' => $expireSeconds],
);
} catch (
NotFoundExceptionInterface|ContainerExceptionInterface|RedisException $e,
NotFoundExceptionInterface|ContainerExceptionInterface|RedisException $e
) {
}

return false;
}

public function eval(string $src, int $keyCount, array $keysAndArgs) : mixed
public function eval(string $src, int $keyCount, array $keysAndArgs): mixed
{
try {
return $this->getRedisCon()->eval($src, $keysAndArgs, $keyCount);
} catch (
NotFoundExceptionInterface|ContainerExceptionInterface|RedisException $e,
NotFoundExceptionInterface|ContainerExceptionInterface|RedisException $e
) {
}

Expand All @@ -60,7 +61,7 @@ public function eval(string $src, int $keyCount, array $keysAndArgs) : mixed
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
protected function getRedisCon() : RedisProxy
protected function getRedisCon(): RedisProxy
{
$container = ApplicationContext::getContainer();
return $container->get(RedisFactory::class)->get($this->pool);
Expand Down
18 changes: 18 additions & 0 deletions php-styler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);
/**
* This file is part of Cloud-Admin project.
*
* @link https://www.cloud-admin.jayjay.cn
* @document https://wiki.cloud-admin.jayjay.cn
* @license https://github.com/swow-cloud/swow-admin/blob/master/LICENSE
*/
use PhpStyler\Config;
use PhpStyler\Files;
use PhpStyler\Styler;

return new Config(
files: new Files(__DIR__ . '/cloud-admin'),
styler: new Styler(),
);

0 comments on commit c7b34ab

Please sign in to comment.