Completed
Push — master ( c27d2d...a49ccc )
by Ondřej
03:50
created

TracingTxHandle::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace Ivory\Connection;
3
4
/**
5
 * {@inheritdoc}
6
 *
7
 * This implementation helps the development by keeping track where exactly the transaction was started. Then, if the
8
 * transaction is not closed properly before the handle gets freed up from memory, a warning is printed with the call
9
 * stack of where the transaction was initialized.
10
 */
11
class TracingTxHandle extends TxHandle
12
{
13
    private $backtrace;
14
15
    public function __construct(IStatementExecution $stmtExec, IObservableTransactionControl $observableTxCtl)
16
    {
17
        parent::__construct($stmtExec, $observableTxCtl);
18
19
        $this->backtrace = debug_backtrace();
20
    }
21
22
    public function __destruct()
23
    {
24
        parent::__destruct();
0 ignored issues
show
Unused Code introduced by
The call to the method Ivory\Connection\TxHandle::__destruct() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
25
26
        // TODO
27
    }
28
}
29