Test Failed
Pull Request — master (#46)
by Jean-Christophe
08:17
created

DAOTransactionsTrait::commitToLevel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Ubiquity\orm\traits;
4
5
/**
6
 * Adds transactions in DAO class.
7
 * Ubiquity\orm\traits$DAOTransactionsTrait
8
 * This class is part of Ubiquity
9
 *
10
 * @author jcheron <[email protected]>
11
 * @version 1.0.0
12
 * @property \Ubiquity\db\Database $db
13
 *
14
 */
15
trait DAOTransactionsTrait {
16
17
	/**
18
	 * Initiates a transaction
19
	 *
20
	 * @return boolean true on success or false on failure
21
	 */
22
	public static function beginTransaction() {
23
		return self::$db->beginTransaction ();
24
	}
25
26
	/**
27
	 * Commits a transaction
28
	 *
29
	 * @return boolean true on success or false on failure
30
	 */
31
	public static function commit() {
32
		return self::$db->commit ();
33
	}
34
35
	/**
36
	 * Commits nested transactions up to level $transactionLevel
37
	 *
38
	 * @param int $transactionLevel
39
	 */
40
	public static function commitToLevel($transactionLevel) {
41
		return self::$db->commitToLevel ( $transactionLevel );
0 ignored issues
show
Bug introduced by
Are you sure the usage of self::db->commitToLevel($transactionLevel) targeting Ubiquity\db\Database::commitToLevel() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
42
	}
43
44
	/**
45
	 * Commits all nested transactions (up to level 0)
46
	 */
47
	public static function commitAll() {
48
		return self::$db->commitAll ();
0 ignored issues
show
Bug introduced by
Are you sure the usage of self::db->commitAll() targeting Ubiquity\db\Database::commitAll() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
49
	}
50
51
	/**
52
	 * Rolls back a transaction
53
	 *
54
	 * @return boolean true on success or false on failure
55
	 */
56
	public static function rollBack() {
57
		return self::$db->rollBack ();
58
	}
59
60
	/**
61
	 * Rolls back nested transactions up to level $transactionLevel
62
	 *
63
	 * @param int $transactionLevel
64
	 */
65
	public static function rollBackToLevel($transactionLevel) {
66
		return self::$db->rollBackToLevel ( $transactionLevel );
0 ignored issues
show
Bug introduced by
Are you sure the usage of self::db->rollBackToLevel($transactionLevel) targeting Ubiquity\db\Database::rollBackToLevel() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
67
	}
68
69
	/**
70
	 * Rolls back all nested transactions (up to level 0)
71
	 */
72
	public static function rollBackAll() {
73
		return self::$db->rollBackAll ();
0 ignored issues
show
Bug introduced by
Are you sure the usage of self::db->rollBackAll() targeting Ubiquity\db\Database::rollBackAll() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
74
	}
75
76
	/**
77
	 * Call a callback with an array of parameters in a transaction
78
	 *
79
	 * @param callable $callback
80
	 * @param mixed ...$parameters
81
	 * @throws \Exception
82
	 * @return mixed
83
	 */
84
	public static function callInTransaction($callback, ...$parameters) {
85
		return self::$db->callInTransaction ( $callback, ...$parameters );
86
	}
87
}
88
89