Passed
Push — main ( 491aa8...6a8c3e )
by James Ekow Abaka
01:50
created

Query::commitNew()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
namespace yentu\database;
3
4
class Query extends DatabaseItem implements Commitable
5
{
6
    private string $query;
7
    private array $bindData;
8
    private string $rollbackQuery;
0 ignored issues
show
introduced by
The private property $rollbackQuery is not used, and could be removed.
Loading history...
9
    private array $rollbackBindData;
0 ignored issues
show
introduced by
The private property $rollbackBindData is not used, and could be removed.
Loading history...
10
    private array $queryData;
11
12
    
13
    public function __construct(string $query, array $bindData = []) 
14
    {
15
        $this->query = $query;
16
        $this->bindData = $bindData;
17
    }
18
    
19
    #[\Override]
20
    public function init()
21
    {
22
        $this->queryData = [
23
            'query' => $this->query,
24
            'query_data' => $this->bindData
25
        ]; 
26
    }
27
    
28
    public function rollback(string $query, array $bindData = []): DatabaseItem
29
    {
30
        $this->queryData['rollback'] = $query;
31
        $this->queryData['rollback_data'] = $bindData;
32
        return $this;
33
    }
34
35
    #[\Override]
36
    public function commitNew()
37
    {
38
        $this->getDriver()->executeQuery($this->queryData);        
0 ignored issues
show
Bug introduced by
The method executeQuery() does not exist on yentu\ChangeLogger. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

38
        $this->getDriver()->/** @scrutinizer ignore-call */ executeQuery($this->queryData);        
Loading history...
39
    }
40
}
41