QueryBuilder   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 40
c 0
b 0
f 0
wmc 6
lcom 1
cbo 7
ccs 12
cts 12
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A insert() 0 4 1
A select() 0 4 1
A update() 0 4 1
A count() 0 4 1
A distinct() 0 4 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder;
6
7
use Puzzle\QueryBuilder\Queries\Delete;
8
use Puzzle\QueryBuilder\Queries\Insert;
9
use Puzzle\QueryBuilder\Queries\Select;
10
use Puzzle\QueryBuilder\Queries\Update;
11
use Puzzle\QueryBuilder\Queries\Snippets;
12
13
class QueryBuilder
14
{
15
    use Traits\EscaperAware;
16
17 1
    public function delete(?string $table = null, ?string $alias = null): Delete
18
    {
19 1
        return (new Delete($table, $alias))->setEscaper($this->escaper);
20
    }
21
22 1
    public function insert(?string $table = null): Insert
23
    {
24 1
        return (new Insert($table))->setEscaper($this->escaper);
25
    }
26
27
    /**
28
     * @param string|array $columns
29
     */
30 1
    public function select($columns = null): Select
31
    {
32 1
        return (new Select($columns))->setEscaper($this->escaper);
0 ignored issues
show
Bug introduced by
It seems like $columns defined by parameter $columns on line 30 can also be of type null or string; however, Puzzle\QueryBuilder\Queries\Select::__construct() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
33
    }
34
35 1
    public function update(?string $table = null, ?string $alias = null): Update
36
    {
37 1
        return (new Update($table, $alias))->setEscaper($this->escaper);
38
    }
39
40
    /**
41
     * @param Snippet|string $columnName
42
     */
43 1
    public function count($columnName, ?string $alias = null): Snippets\Count
44
    {
45 1
        return (new Snippets\Count($columnName, $alias));
46
    }
47
48 1
    public function distinct(string $columnName): Snippets\Distinct
49
    {
50 1
        return (new Snippets\Distinct($columnName));
51
    }
52
}
53