FunctionCall::build()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\SqlParser\Components;
6
7
use PhpMyAdmin\SqlParser\Component;
8
9
use function is_array;
10
11
/**
12
 * Parses a function call.
13
 */
14
final class FunctionCall implements Component
15
{
16
    /**
17
     * The name of this function.
18
     */
19
    public string|null $name = null;
20
21
    /**
22
     * The list of parameters.
23
     */
24
    public ArrayObj|null $parameters = null;
25
26
    /**
27
     * @param string|null            $name       the name of the function to be called
28
     * @param string[]|ArrayObj|null $parameters the parameters of this function
29
     */
30 34
    public function __construct(string|null $name = null, array|ArrayObj|null $parameters = null)
31
    {
32 34
        $this->name = $name;
33 34
        if (is_array($parameters)) {
34 2
            $this->parameters = new ArrayObj($parameters);
35 32
        } elseif ($parameters instanceof ArrayObj) {
36 2
            $this->parameters = $parameters;
37
        }
38
    }
39
40 4
    public function build(): string
41
    {
42 4
        return $this->name . $this->parameters;
43
    }
44
45
    public function __toString(): string
46
    {
47
        return $this->build();
48
    }
49
}
50