From b519765adbb4e51cc12fab6c9bae29f2b0acdcd5 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 28 Oct 2022 11:12:35 +0200 Subject: [PATCH] cleanup --- src/Illuminate/Console/CacheCommandMutex.php | 34 ++++++++++++++----- src/Illuminate/Console/CommandMutex.php | 8 ++--- src/Illuminate/Contracts/Console/Isolated.php | 2 -- tests/Console/CacheCommandMutexTest.php | 10 +++--- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Illuminate/Console/CacheCommandMutex.php b/src/Illuminate/Console/CacheCommandMutex.php index be24e24e95e1..c1e9b0b0e9bc 100644 --- a/src/Illuminate/Console/CacheCommandMutex.php +++ b/src/Illuminate/Console/CacheCommandMutex.php @@ -1,7 +1,5 @@ cache = $cache; } + /** + * Attempt to obtain a command mutex for the given command. + * + * @param \Illuminate\Console\Command $command + * @return bool + */ public function create($command) { return $this->cache->store($this->store)->add( @@ -42,25 +46,37 @@ public function create($command) ); } - public function exists($command) + /** + * Release the mutex for the given command. + * + * @param \Illuminate\Console\Command $command + * @return bool + */ + public function release($command) { - return $this->cache->store($this->store)->has( + return $this->cache->store($this->store)->forget( $this->commandMutexName($command) ); } - public function release($command) + /** + * Determine if a command mutex exists for the given command. + * + * @param \Illuminate\Console\Command $command + * @return bool + */ + public function exists($command) { - return $this->cache->store($this->store)->forget( + return $this->cache->store($this->store)->has( $this->commandMutexName($command) ); } /** - * @param Command $command + * @param \Illuminate\Console\Command $command * @return string */ - protected function commandMutexName($command): string + protected function commandMutexName($command) { return 'framework'.DIRECTORY_SEPARATOR.'command-'.$command->getName(); } @@ -71,7 +87,7 @@ protected function commandMutexName($command): string * @param string|null $store * @return $this */ - public function useStore($store): static + public function useStore($store) { $this->store = $store; diff --git a/src/Illuminate/Console/CommandMutex.php b/src/Illuminate/Console/CommandMutex.php index 3b1a46a86d76..c883ebf629d1 100644 --- a/src/Illuminate/Console/CommandMutex.php +++ b/src/Illuminate/Console/CommandMutex.php @@ -1,7 +1,5 @@