ORMHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 27
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0
wmc 4

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 27
    public static function processLiteral($sql, &$params)
8
    {
9 27
        if (!is_array($params)) {
10 3
            return $sql;
11
        }
12
13 25
        foreach ($params as $field => $param) {
14 22
            if ($param instanceof Literal) {
15 6
                $literalValue = $param->getLiteralValue();
16 6
                $sql = preg_replace(
17
                    [
18 6
                        "/\\[\\[$field\\]\\]/",
19 6
                        "/:$field([^\\d\\w]|$)/"
20 6
                    ],
21
                    [
22 6
                        $literalValue,
23 6
                        "$literalValue\$1"
24 6
                    ],
25
                    $sql
26 6
                );
27 6
                unset($params[$field]);
28 6
            }
29 25
        }
30
31 25
        return $sql;
32
    }
33
}
34