Completed
Push — 3.x-builder-quoter ( 067851 )
by Paul
02:03
created

UpdateBuilder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 36
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A buildTable() 0 5 1
A buildValuesForUpdate() 0 13 3
1
<?php
2
namespace Aura\SqlQuery\Common;
3
4
use Aura\SqlQuery\AbstractBuilder;
5
6
class UpdateBuilder extends AbstractBuilder
7
{
8
    /**
9
     *
10
     * Builds the table clause.
11
     *
12
     * @return null
13
     *
14
     */
15 16
    public function buildTable($table)
16
    {
17 16
        $table = $this->quoter->quoteName($table);
0 ignored issues
show
Bug introduced by
The property quoter does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18 16
        return " {$table}";
19
    }
20
21
    /**
22
     *
23
     * Builds the updated columns and values of the statement.
24
     *
25
     * @return string
26
     *
27
     */
28 16
    public function buildValuesForUpdate($col_values)
29
    {
30 16
        $values = array();
31 16
        foreach ($col_values as $col => $value) {
32 16
            $col = $this->quoter->quoteName($col);
33 16
            if ($value instanceof RawValue) {
0 ignored issues
show
Bug introduced by
The class Aura\SqlQuery\Common\RawValue does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
34
                $value = $this->quoter->quoteNamesIn((string) $value);
35
            }
36 16
            $values[] = "{$col} = {$value}";
37 16
        }
38
39 16
        return PHP_EOL . 'SET' . $this->indentCsv($values);
40
    }
41
}
42