Passed
Branch v1.5.1 (94eede)
by Wanderson
02:06
created

Transaction::rollback()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Win\Repositories\Database;
4
5
use PDO;
6
7
/**
8
 * Transações no Banco de Dados
9
 */
10
class Transaction
11
{
12
	/** @var PDO */
13
	private $pdo;
14
15
	/**
16
	 * Inicia a Transação
17
	 * @param Connection $conn
18
	 */
19
	public function __construct(Connection $conn = null)
20
	{
21
		$conn = $conn ?? MysqlConnection::instance();
22
		$this->pdo = $conn->getPdo();
23
		$this->pdo->beginTransaction();
24
	}
25
26
	/**
27
	 * Completa a Transação
28
	 */
29
	public function commit()
30
	{
31
		$this->pdo->commit();
32
	}
33
34
	/**
35
	 * Cancela a Transação
36
	 */
37
	public function rollback()
38
	{
39
		$this->pdo->rollBack();
40
	}
41
}
42