Passed
Push — main ( c93099...0e69d1 )
by James Ekow Abaka
17:15
created

Query::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
namespace yentu\database;
3
4
class Query extends DatabaseItem implements Commitable, Initializable
5
{
6
    private string $query;
7
    private array $bindData;
8
    private array $queryData;
9
10
    
11
    public function __construct(string $query, array $bindData = []) 
12
    {
13
        $this->query = $query;
14
        $this->bindData = $bindData;
15
    }
16
    
17
    #[\Override]
18
    public function initialize(): void
19
    {
20
        $this->queryData = [
21
            'query' => $this->query,
22
            'bind' => $this->bindData
23
        ]; 
24
        $this->new = true;
25
    }
26
    
27
    public function rollback(string $query, array $bindData = []): DatabaseItem
28
    {
29
        $this->queryData['rollback_query'] = $query;
30
        $this->queryData['rollback_bind'] = $bindData;
31
        $this->new = true;
32
        return $this;
33
    }
34
35
    #[\Override]
36
    public function commitNew()
37
    {
38
        $this->getChangeLogger()->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->getChangeLogger()->/** @scrutinizer ignore-call */ executeQuery($this->queryData);
Loading history...
39
    }
40
}
41