Skip to content

Commit 0383042

Browse files
author
Babichev Maxim
committed
code refactor for codeclimate
1 parent e076a76 commit 0383042

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/Services/LockService.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,23 @@ protected function lockProvider($self, string $name, int $seconds): Lock
6464
* @var LockProvider $store
6565
*/
6666
$store = Cache::getStore();
67-
$enabled = config('wallet.lock.enabled', false);
67+
} catch (\Throwable $throwable) {
68+
// todo: write error's
69+
}
6870

69-
if ($enabled && $store instanceof LockProvider) {
70-
$class = \get_class($self);
71-
$uniqId = $class . $this->uniqId;
72-
if ($self instanceof Model) {
73-
$uniqId = $class . $self->getKey();
74-
}
71+
$enabled = false;
72+
if (isset($store)) {
73+
$enabled = config('wallet.lock.enabled', false);
74+
}
7575

76-
return $store->lock("$name.$uniqId", $seconds);
76+
if ($enabled && $store instanceof LockProvider) {
77+
$class = \get_class($self);
78+
$uniqId = $class . $this->uniqId;
79+
if ($self instanceof Model) {
80+
$uniqId = $class . $self->getKey();
7781
}
78-
} catch (\Throwable $throwable) {
79-
// write error's
82+
83+
return $store->lock("$name.$uniqId", $seconds);
8084
}
8185

8286
return new EmptyLock();

0 commit comments

Comments
 (0)