Concat::call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 13
ccs 7
cts 7
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * @license     http://opensource.org/licenses/mit-license.php MIT
5
 * @link        https://github.com/nicoSWD
6
 * @author      Nicolas Oelgart <[email protected]>
7
 */
8
namespace nicoSWD\Rule\Grammar\JavaScript\Methods;
9
10
use nicoSWD\Rule\Grammar\CallableFunction;
11
use nicoSWD\Rule\TokenStream\Token\BaseToken;
12
use nicoSWD\Rule\TokenStream\Token\TokenArray;
13
use nicoSWD\Rule\TokenStream\Token\TokenString;
14
15
final class Concat extends CallableFunction
16
{
17 6
    public function call(?BaseToken ...$parameters): BaseToken
18
    {
19 6
        $value = $this->token->getValue();
0 ignored issues
show
Bug Best Practice introduced by
The property token does not exist on nicoSWD\Rule\Grammar\JavaScript\Methods\Concat. Did you maybe forget to declare it?
Loading history...
20
21 6
        foreach ($parameters as $parameter) {
22 6
            if ($parameter instanceof TokenArray) {
23 2
                $value .= implode(',', $parameter->toArray());
24
            } else {
25 6
                $value .= $parameter->getValue();
0 ignored issues
show
Bug introduced by
The method getValue() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
                $value .= $parameter->/** @scrutinizer ignore-call */ getValue();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
            }
27
        }
28
29 6
        return new TokenString($value);
30
    }
31
}
32