Passed
Push — master ( 6ee3f7...8f2389 )
by Nico
01:24
created

EndsWith   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A call() 0 6 1
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\TokenBool;
13
14
final class EndsWith extends CallableFunction
15
{
16 4
    public function call(?BaseToken ...$parameters): BaseToken
17
    {
18 4
        $needle = $this->parseParameter($parameters, 0);
19 4
        $value = strpos($this->token->getValue(), $needle->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

19
        $value = strpos($this->token->/** @scrutinizer ignore-call */ getValue(), $needle->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...
20
21 4
        return new TokenBool($value === strlen($needle->getValue()) - 1);
22
    }
23
}
24