FunctionCall   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 34
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 1
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 3 1
A __construct() 0 7 3
A __toString() 0 3 1
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