DatabaseQueryBuilder   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 44
ccs 11
cts 13
cp 0.8462
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 13 3
A setDefaultsFromConfiguration() 0 8 2
1
<?php
2
3
namespace Anax\DatabaseQueryBuilder;
4
5
use Anax\Database\Database;
6
use Anax\DatabaseQueryBuilder\Exception\BuildException;
7
8
/**
9
 * Build SQL queries by method calling.
10
 */
11
class DatabaseQueryBuilder extends Database
12
{
13
    use QueryBuilderTrait;
14
15
16
17
    /**
18
     * Update builder settings from active configuration.
19
     *
20
     * @return void
21
     */
22 2
    public function setDefaultsFromConfiguration()
23
    {
24 2
        if ($this->options['dsn']) {
25 2
            $dsn = explode(':', $this->options['dsn']);
26 2
            $this->setSQLDialect($dsn[0]);
27
        }
28
29 2
        $this->setTablePrefix($this->options['table_prefix']);
30 2
    }
31
32
33
34
    /**
35
     * Execute a SQL-query.
36
     *
37
     * @param string|null|array $query  the SQL statement (or $params)
38
     * @param array             $params the params array
39
     *
40
     * @return self
41
     */
42 2
    public function execute($query = null, array $params = []) : object
43
    {
44
        // When using one argument and its array, assume its $params
45 2
        if (is_array($query)) {
46
            $params = $query;
47
            $query = null;
48
        }
49
50 2
        if (!$query) {
51 2
            $query = $this->getSQL();
52
        }
53
54 2
        return parent::execute($query, $params);
0 ignored issues
show
Bug introduced by
It seems like $query can also be of type array and null; however, parameter $query of Anax\Database\Database::execute() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

54
        return parent::execute(/** @scrutinizer ignore-type */ $query, $params);
Loading history...
55
    }
56
}
57