Passed
Push — master ( b16987...8b6d77 )
by Maurício
03:49 queued 13s
created

FunctionCall   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 9
dl 0
loc 38
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
     * @var string|null
20
     */
21
    public $name;
22
23
    /**
24
     * The list of parameters.
25
     *
26
     * @var ArrayObj|null
27
     */
28
    public $parameters;
29
30
    /**
31
     * @param string|null            $name       the name of the function to be called
32
     * @param string[]|ArrayObj|null $parameters the parameters of this function
33
     */
34 34
    public function __construct(string|null $name = null, array|ArrayObj|null $parameters = null)
35
    {
36 34
        $this->name = $name;
37 34
        if (is_array($parameters)) {
38 2
            $this->parameters = new ArrayObj($parameters);
39 32
        } elseif ($parameters instanceof ArrayObj) {
40 2
            $this->parameters = $parameters;
41
        }
42
    }
43
44 4
    public function build(): string
45
    {
46 4
        return $this->name . $this->parameters;
47
    }
48
49
    public function __toString(): string
50
    {
51
        return $this->build();
52
    }
53
}
54