Passed
Push — master ( b12b63...8e6e26 )
by Henri
08:15
created

DebugTrait::debug()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 6
c 1
b 0
f 1
nc 3
nop 1
dl 0
loc 13
rs 10
1
<?php
2
3
namespace HnrAzevedo\Datamanager;
4
5
trait DebugTrait
6
{
7
    protected string $lastQuery = '';
8
    protected array $lastData = [];
9
10
    public function debug(bool $array = false)
11
    {
12
        if($array){
13
            return ['query' => $this->lastQuery, 'data' => $this->lastData];
14
        }
15
        
16
        $query = $this->lastQuery;
17
18
        foreach($this->lastData as $name => $value){
19
            $query = str_replace(":{$name}","'{$value}'",$query);
20
        }
21
22
        return $query;
23
    }    
24
25
    
26
27
}
28