Skip to content

Commit 171be0d

Browse files
committed
Refactoring
1 parent b82dce1 commit 171be0d

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

src/Relations/Traits/IsJsonRelation.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,15 @@ protected function getJsonGrammar(Builder $query): JsonGrammar
162162
{
163163
$driver = $query->getConnection()->getDriverName();
164164

165-
switch ($driver) {
166-
case 'mysql':
167-
return $query->getConnection()->withTablePrefix(new MySqlGrammar());
168-
case 'pgsql':
169-
return $query->getConnection()->withTablePrefix(new PostgresGrammar());
170-
case 'sqlite':
171-
return $query->getConnection()->withTablePrefix(new SqliteGrammar());
172-
case 'sqlsrv':
173-
return $query->getConnection()->withTablePrefix(new SqlServerGrammar());
174-
}
175-
176-
throw new RuntimeException('This database is not supported.'); // @codeCoverageIgnore
165+
return $query->getConnection()->withTablePrefix(
166+
match ($driver) {
167+
'mysql' => new MySqlGrammar(),
168+
'pgsql' => new PostgresGrammar(),
169+
'sqlite' => new SqliteGrammar(),
170+
'sqlsrv' => new SqlServerGrammar(),
171+
default => throw new RuntimeException('This database is not supported.') // @codeCoverageIgnore
172+
}
173+
);
177174
}
178175

179176
/**

0 commit comments

Comments
 (0)