From eb3f6f8337050cc31fe1a1164240fe205e33b167 Mon Sep 17 00:00:00 2001 From: Mohamed Said Date: Thu, 28 Mar 2019 07:06:56 +0200 Subject: [PATCH] use property_exists --- src/Watchers/CacheWatcher.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Watchers/CacheWatcher.php b/src/Watchers/CacheWatcher.php index 13601161e..85ad98a1f 100644 --- a/src/Watchers/CacheWatcher.php +++ b/src/Watchers/CacheWatcher.php @@ -80,7 +80,7 @@ public function recordKeyWritten(KeyWritten $event) 'type' => 'set', 'key' => $event->key, 'value' => $event->value, - 'expiration' => $event->seconds ?? $event->minutes, + 'expiration' => $this->formatExpiration($event), ])); } @@ -102,6 +102,16 @@ public function recordKeyForgotten(KeyForgotten $event) ])); } + /** + * @param \Illuminate\Cache\Events\KeyWritten $event + * @return mixed + */ + protected function formatExpiration(KeyWritten $event) + { + return property_exists($event, 'seconds') + ? $event->seconds : $event->minutes * 60; + } + /** * Determine if the event should be ignored. *