Passed
Push — main ( b49db2...9f0690 )
by Sammy
08:20
created

Grammar::backtick()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A Grammar::rawOrBacktick() 0 3 2
1
<?php
2
3
namespace HexMakina\Crudites\Grammar;
4
5
class Grammar
6
{
7
    /**
8
     * Adds backticks to a reference.
9
     *
10
     * @param $reference The reference to add backticks to.
0 ignored issues
show
Bug introduced by
The type HexMakina\Crudites\Grammar\The was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
     * @return string The reference with backticks added.
12
     */
13
14
    public static function rawOrBacktick($reference): string
15
    {
16
        return is_string($reference) ? $reference : self::identifier($reference);
17
    }
18
19
    public static function identifier($reference): string
20
    {
21
        if (is_array($reference)) {
22
            $tick = $reference[0];
23
            if (isset($reference[1])) {
24
                $tick = $tick . '`.`' . $reference[1];
25
            }
26
            $reference = $tick;
27
        }
28
29
        return sprintf('`%s`', $reference);
30
    }
31
}
32