ORMHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Test Coverage

Coverage 60.87%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 2
b 0
f 0
dl 0
loc 32
ccs 14
cts 23
cp 0.6087
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A processLiteral() 0 25 4
1
<?php
2
3
namespace ByJG\MicroOrm;
4
5
class ORMHelper
6
{
7
    /**
8
     * @param string $sql
9
     * @param array $params
10
     * @return string
11
     */
12 46
    public static function processLiteral($sql, &$params)
13
    {
14 46
        if (!is_array($params)) {
0 ignored issues
show
introduced by
The condition is_array($params) is always true.
Loading history...
15 6
            return $sql;
16
        }
17
18 42
        foreach ($params as $field => $param) {
19 38
            if ($param instanceof Literal) {
20 12
                $literalValue = $param->getLiteralValue();
21 12
                $sql = preg_replace(
22
                    [
23 12
                        "/\\[\\[$field\\]\\]/",
24 12
                        "/:$field([^\\d\\w]|$)/"
25
                    ],
26
                    [
27 12
                        $literalValue,
28 12
                        "$literalValue\$1"
29
                    ],
30 12
                    $sql
31
                );
32 38
                unset($params[$field]);
33
            }
34
        }
35
36 42
        return $sql;
37
    }
38
}
39