Skip to content

Commit 516607e

Browse files
authored
extract cache-file-not-found-or-stale (#122)
1 parent 34f2350 commit 516607e

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/Sushi.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,7 @@ public static function bootSushi()
6767
static::setSqliteConnection($cachePath);
6868
},
6969
'cache-file-not-found-or-stale' => function () use ($cachePath, $dataPath, $instance) {
70-
file_put_contents($cachePath, '');
71-
72-
static::setSqliteConnection($cachePath);
73-
74-
$instance->migrate();
75-
76-
touch($cachePath, filemtime($dataPath));
70+
static::cacheFileNotFoundOrStale($cachePath, $dataPath, $instance);
7771
},
7872
'no-caching-capabilities' => function () use ($instance) {
7973
static::setSqliteConnection(':memory:');
@@ -101,6 +95,17 @@ public static function bootSushi()
10195
}
10296
}
10397

98+
protected static function cacheFileNotFoundOrStale($cachePath, $dataPath, $instance)
99+
{
100+
file_put_contents($cachePath, '');
101+
102+
static::setSqliteConnection($cachePath);
103+
104+
$instance->migrate();
105+
106+
touch($cachePath, filemtime($dataPath));
107+
}
108+
104109
protected function newRelatedInstance($class)
105110
{
106111
return tap(new $class, function ($instance) {

0 commit comments

Comments
 (0)