From d1ebc03fd0ab04cafc689da9b892c0bc2610cbb3 Mon Sep 17 00:00:00 2001 From: EriBloo <19932449+EriBloo@users.noreply.github.com> Date: Mon, 14 Oct 2024 21:36:00 +0000 Subject: [PATCH] extract method --- src/Concerns/CacheObjectActions.php | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/Concerns/CacheObjectActions.php b/src/Concerns/CacheObjectActions.php index 4d93976..cb67189 100644 --- a/src/Concerns/CacheObjectActions.php +++ b/src/Concerns/CacheObjectActions.php @@ -16,11 +16,8 @@ trait CacheObjectActions */ public function store(mixed $value): string { - /** @var CacheObjectDriver $driver */ - $driver = app() - ->make(CacheObjectDriver::class); - - return $driver->set($value, $this); + return $this->resolveDriver() + ->set($value, $this); } /** @@ -28,19 +25,18 @@ public function store(mixed $value): string */ public function retrieve(): mixed { - /** @var CacheObjectDriver $driver */ - $driver = app() - ->make(CacheObjectDriver::class); - - return $driver->get($this); + return $this->resolveDriver() + ->get($this); } public function delete(): bool { - /** @var CacheObjectDriver $driver */ - $driver = app() - ->make(CacheObjectDriver::class); + return $this->resolveDriver() + ->delete($this); + } - return $driver->delete($this); + protected function resolveDriver(): CacheObjectDriver + { + return app()->make(CacheObjectDriver::class); } }