Passed
Push — master ( 0d676e...35e015 )
by Wilmer
04:03
created

src/Transaction.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Sqlite;
6
7
use Throwable;
8
use Yiisoft\Db\Driver\Pdo\AbstractPdoTransaction;
0 ignored issues
show
The type Yiisoft\Db\Driver\Pdo\AbstractPdoTransaction was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use Yiisoft\Db\Exception\Exception;
10
use Yiisoft\Db\Exception\InvalidConfigException;
11
use Yiisoft\Db\Exception\NotSupportedException;
12
13
/**
14
 * Implements the SQLite Server specific transaction.
15
 */
16
final class Transaction extends AbstractPdoTransaction
17
{
18
    /**
19
     * Sets the isolation level of the current transaction.
20
     *
21
     * @param string $level The transaction isolation level to use for this transaction.
22
     *
23
     * @see \Yiisoft\Db\Transaction\TransactionInterface::READ_UNCOMMITTED
24
     * @see \Yiisoft\Db\Transaction\TransactionInterface::SERIALIZABLE
25
     *
26
     * @throws Exception
27
     * @throws InvalidConfigException
28
     * @throws NotSupportedException
29
     * @throws Throwable When unsupported isolation levels are used. SQLite only supports `SERIALIZABLE`
30
     * and `READ UNCOMMITTED`.
31
     *
32
     * @link http://www.sqlite.org/pragma.html#pragma_read_uncommitted
33
     */
34 4
    protected function setTransactionIsolationLevel(string $level): void
35
    {
36
        switch ($level) {
37 4
            case self::SERIALIZABLE:
38 1
                $this->db->createCommand('PRAGMA read_uncommitted = False;')->execute();
39 1
                break;
40 4
            case self::READ_UNCOMMITTED:
41 3
                $this->db->createCommand('PRAGMA read_uncommitted = True;')->execute();
42 3
                break;
43
            default:
44 1
                throw new NotSupportedException(
45 1
                    self::class . ' only supports transaction isolation levels READ UNCOMMITTED and SERIALIZABLE.'
46 1
                );
47
        }
48
    }
49
}
50