diff --git a/src/Sushi.php b/src/Sushi.php index eaa92b6..c84ad50 100644 --- a/src/Sushi.php +++ b/src/Sushi.php @@ -67,13 +67,7 @@ public static function bootSushi() static::setSqliteConnection($cachePath); }, 'cache-file-not-found-or-stale' => function () use ($cachePath, $dataPath, $instance) { - file_put_contents($cachePath, ''); - - static::setSqliteConnection($cachePath); - - $instance->migrate(); - - touch($cachePath, filemtime($dataPath)); + static::cacheFileNotFoundOrStale($cachePath, $dataPath, $instance); }, 'no-caching-capabilities' => function () use ($instance) { static::setSqliteConnection(':memory:'); @@ -101,6 +95,17 @@ public static function bootSushi() } } + protected static function cacheFileNotFoundOrStale($cachePath, $dataPath, $instance) + { + file_put_contents($cachePath, ''); + + static::setSqliteConnection($cachePath); + + $instance->migrate(); + + touch($cachePath, filemtime($dataPath)); + } + protected function newRelatedInstance($class) { return tap(new $class, function ($instance) {