@@ -193,25 +193,14 @@ public function createTable(): void
193193 $ conn = $ this ->getConnection ();
194194 $ driver = $ this ->getDriver ();
195195
196- switch ($ driver ) {
197- case 'mysql ' :
198- $ sql = "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(44) NOT NULL, $ this ->expirationCol INTEGER UNSIGNED NOT NULL) COLLATE utf8mb4_bin, ENGINE = InnoDB " ;
199- break ;
200- case 'sqlite ' :
201- $ sql = "CREATE TABLE $ this ->table ( $ this ->idCol TEXT NOT NULL PRIMARY KEY, $ this ->tokenCol TEXT NOT NULL, $ this ->expirationCol INTEGER) " ;
202- break ;
203- case 'pgsql ' :
204- $ sql = "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(64) NOT NULL, $ this ->expirationCol INTEGER) " ;
205- break ;
206- case 'oci ' :
207- $ sql = "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR2(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR2(64) NOT NULL, $ this ->expirationCol INTEGER) " ;
208- break ;
209- case 'sqlsrv ' :
210- $ sql = "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(64) NOT NULL, $ this ->expirationCol INTEGER) " ;
211- break ;
212- default :
213- throw new \DomainException (sprintf ('Creating the lock table is currently not implemented for platform "%s". ' , $ driver ));
214- }
196+ $ sql = match ($ driver ) {
197+ 'mysql ' => "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(44) NOT NULL, $ this ->expirationCol INTEGER UNSIGNED NOT NULL) COLLATE utf8mb4_bin, ENGINE = InnoDB " ,
198+ 'sqlite ' => "CREATE TABLE $ this ->table ( $ this ->idCol TEXT NOT NULL PRIMARY KEY, $ this ->tokenCol TEXT NOT NULL, $ this ->expirationCol INTEGER) " ,
199+ 'pgsql ' => "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(64) NOT NULL, $ this ->expirationCol INTEGER) " ,
200+ 'oci ' => "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR2(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR2(64) NOT NULL, $ this ->expirationCol INTEGER) " ,
201+ 'sqlsrv ' => "CREATE TABLE $ this ->table ( $ this ->idCol VARCHAR(64) NOT NULL PRIMARY KEY, $ this ->tokenCol VARCHAR(64) NOT NULL, $ this ->expirationCol INTEGER) " ,
202+ default => throw new \DomainException (sprintf ('Creating the lock table is currently not implemented for platform "%s". ' , $ driver )),
203+ };
215204
216205 $ conn ->exec ($ sql );
217206 }
@@ -243,19 +232,13 @@ private function getDriver(): string
243232 */
244233 private function getCurrentTimestampStatement (): string
245234 {
246- switch ($ this ->getDriver ()) {
247- case 'mysql ' :
248- return 'UNIX_TIMESTAMP() ' ;
249- case 'sqlite ' :
250- return 'strftime( \'%s \', \'now \') ' ;
251- case 'pgsql ' :
252- return 'CAST(EXTRACT(epoch FROM NOW()) AS INT) ' ;
253- case 'oci ' :
254- return '(SYSDATE - TO_DATE( \'19700101 \', \'yyyymmdd \'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600 ' ;
255- case 'sqlsrv ' :
256- return 'DATEDIFF(s, \'1970-01-01 \', GETUTCDATE()) ' ;
257- default :
258- return (string ) time ();
259- }
235+ return match ($ this ->getDriver ()) {
236+ 'mysql ' => 'UNIX_TIMESTAMP() ' ,
237+ 'sqlite ' => 'strftime( \'%s \', \'now \') ' ,
238+ 'pgsql ' => 'CAST(EXTRACT(epoch FROM NOW()) AS INT) ' ,
239+ 'oci ' => '(SYSDATE - TO_DATE( \'19700101 \', \'yyyymmdd \'))*86400 - TO_NUMBER(SUBSTR(TZ_OFFSET(sessiontimezone), 1, 3))*3600 ' ,
240+ 'sqlsrv ' => 'DATEDIFF(s, \'1970-01-01 \', GETUTCDATE()) ' ,
241+ default => (string ) time (),
242+ };
260243 }
261244}
0 commit comments