private function callOnWrappedDriver(Connection $connection, $method) { $connection = $connection->getWrappedConnection(); if (!$connection instanceof ConnectionWrapper) { $class = get_class($connection); $interface = ConnectionWrapper::class; throw new WrapperException("This driver cannot {$method} on {$class} because it does not implements {$interface}"); } $driver = $connection->wrappedDriver(); $connection = new Connection(['pdo' => $connection->wrappedConnection()], $driver); return $driver->{$method}($connection); }