Sqlite   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A columnName() 0 15 4
A obtainPartsToDisable() 0 7 1
1
<?php
2
3
namespace BfwSql\Queries\SGBD;
4
5
class Sqlite extends AbstractSGBD
6
{
7
    /**
8
     * {@inheritdoc}
9
     * 
10
     * Disable all joins for update queries with sqlite
11
     */
12
    protected function obtainPartsToDisable(): array
13
    {
14
        return [
15
            'delete' => [],
16
            'insert' => [],
17
            'select' => [],
18
            'update' => ['join', 'joinLeft', 'joinRight']
19
        ];
20
    }
21
    
22
    /**
23
     * {@inheritdoc}
24
     * 
25
     * Not add table name/shortcut before column name for an update query.
26
     */
27
    public function columnName(
28
        string $colName,
29
        string $tableName,
30
        bool $isFunction,
31
        bool $isJoker
32
    ): string {
33
        if ($this->obtainRequestType() === 'update') {
34
            if ($isFunction === true || $isJoker === true) {
35
                return $colName;
36
            } else {
37
                return '`'.$colName.'`';
38
            }
39
        }
40
        
41
        return parent::columnName($colName, $tableName, $isFunction, $isJoker);
42
    }
43
}
44