Completed
Push — master ( 2a4290...c23846 )
by Nico
01:31
created

Concat::call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 21
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 21
ccs 11
cts 11
cp 1
rs 9.3142
c 0
b 0
f 0
cc 3
eloc 12
nc 3
nop 1
crap 3
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @license     http://opensource.org/licenses/mit-license.php MIT
7
 * @link        https://github.com/nicoSWD
8
 * @author      Nicolas Oelgart <[email protected]>
9
 */
10
namespace nicoSWD\Rules\Grammar\JavaScript\Methods;
11
12
use nicoSWD\Rules\Core\CallableFunction;
13
use nicoSWD\Rules\Tokens\BaseToken;
14
use nicoSWD\Rules\Tokens\TokenArray;
15
use nicoSWD\Rules\Tokens\TokenString;
16
17
final class Concat extends CallableFunction
18
{
19
    /**
20
     * @param BaseToken $parameters
21
     * @param BaseToken $parameters...
0 ignored issues
show
Documentation introduced by
There is no parameter named $parameters.... Did you maybe mean $parameters?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
22
     * @return BaseToken
23
     */
24 6
    public function call($parameters = null): BaseToken
25
    {
26 6
        $value = $this->token->getValue();
27
28
        /** @var BaseToken[] $parameters */
29 6
        $parameters = func_get_args();
30
31 6
        foreach ($parameters as $parameter) {
32 6
            if ($parameter instanceof TokenArray) {
33 2
                $value .= implode(',', $parameter->toArray());
34
            } else {
35 6
                $value .= $parameter->getValue();
36
            }
37
        }
38
39 6
        return new TokenString(
40 6
            $value,
41 6
            $this->token->getOffset(),
42 6
            $this->token->getStack()
43
        );
44
    }
45
}
46