GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Database::nestable()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Pimf
4
 *
5
 * @copyright Copyright (c)  Gjero Krsteski (http://krsteski.de)
6
 * @license   http://opensource.org/licenses/MIT MIT
7
 */
8
9
namespace Pimf;
10
11
/**
12
 * @package Pimf
13
 * @author  Gjero Krsteski <[email protected]>
14
 */
15
class Database extends \PDO
16
{
17
    /**
18
     * The current transaction level.
19
     *
20
     * @var int
21
     */
22
    protected $transLevel = 0;
23
24
    /**
25
     * Check database drivers that support savepoints.
26
     *
27
     * @return bool
28
     */
29
    public function nestable()
30
    {
31
        return in_array(
32
            $this->getAttribute(\PDO::ATTR_DRIVER_NAME), array("pgsql", "mysql")
33
        );
34
    }
35
36
    /**
37
     * @return bool|void
38
     */
39
    public function beginTransaction()
40
    {
41
        if ($this->transLevel == 0 || !$this->nestable()) {
42
            parent::beginTransaction();
43
        } else {
44
            $this->exec("SAVEPOINT LEVEL{$this->transLevel}");
45
        }
46
47
        $this->transLevel++;
48
    }
49
50
    /**
51
     * @return bool|void
52
     */
53
    public function commit()
54
    {
55
        $this->transLevel--;
56
57
        if ($this->transLevel == 0 || !$this->nestable()) {
58
            parent::commit();
59
        } else {
60
            $this->exec("RELEASE SAVEPOINT LEVEL{$this->transLevel}");
61
        }
62
    }
63
64
    /**
65
     * @return bool|void
66
     * @throws \LogicException
67
     */
68
    public function rollBack()
69
    {
70
        if ($this->transLevel == 0) {
71
            throw new \LogicException('trying to rollback without a transaction-start', 25000);
72
        }
73
74
        $this->transLevel--;
75
76
        if ($this->transLevel == 0 || !$this->nestable()) {
77
            parent::rollBack();
78
        } else {
79
            $this->exec("ROLLBACK TO SAVEPOINT LEVEL{$this->transLevel}");
80
        }
81
    }
82
}
83