Grammar   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A identifier() 0 11 3
1
<?php
2
3
namespace HexMakina\Crudites\Grammar;
4
5
class Grammar
6
{
7
    /**
8
     * Surrounds a string with backticks by default
9
     * @param string|array $reference : a string or an array with 2 elements, the first being the table name and the second the column name
10
     * @param string $tick : the character to use for surrounding the string
11
     * @return string : the string surrounded by the tick character
12
     * 
13
     */
14
    public static function identifier($reference, $tick='`'): string
15
    {
16
        if (is_array($reference)) {
17
            $identifier = $reference[0];
18
            if (isset($reference[1])) {
19
                $identifier = $identifier.$tick . '.' . $tick.$reference[1];
20
            }
21
            $reference = $identifier;
22
        }
23
24
        return sprintf('`%s`', $reference);
25
    }
26
}
27