Localization_Parser_Token_Javascript   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 19
c 2
b 0
f 0
dl 0
loc 62
rs 10
wmc 13

9 Methods

Rating   Name   Duplication   Size   Complexity  
A isExplanationFunction() 0 3 1
A isOpeningFuncParams() 0 3 1
A isArgumentSeparator() 0 3 1
A isTranslationFunction() 0 3 2
A isVariableOrFunction() 0 3 2
A getFunctionNames() 0 4 1
A isClosingFuncParams() 0 3 1
A isEncapsedString() 0 3 1
A parseDefinition() 0 17 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppLocalize;
6
7
use JTokenizer\JTokenizer;
8
9
class Localization_Parser_Token_Javascript extends Localization_Parser_Token
10
{
11
    protected function parseDefinition() : void
12
    {
13
        // some entries are strings, like parenthesises, semicolons and the like.
14
        if(is_string($this->definition))
15
        {
16
            $this->token = $this->definition;
17
            $this->value = null;
18
            
19
            if(isset($this->parentToken)) {
20
                $this->line = $this->parentToken->getLine();
0 ignored issues
show
Bug introduced by
The method getLine() 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

20
                /** @scrutinizer ignore-call */ 
21
                $this->line = $this->parentToken->getLine();

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...
21
            }
22
        }
23
        else
24
        {
25
            $this->token = JTokenizer::getTokenName($this->definition[0]);
26
            $this->value = $this->definition[1];
27
            $this->line = $this->definition[2];
28
        }
29
    }
30
    
31
    public function getFunctionNames() : array
32
    {
33
        return array(
34
            't'
35
        );
36
    }
37
    
38
    public function isOpeningFuncParams() : bool
39
    {
40
        return $this->getToken() === '(';
41
    }
42
    
43
    public function isClosingFuncParams() : bool
44
    {
45
        return $this->getToken() === ')';
46
    }
47
    
48
    public function isEncapsedString() : bool
49
    {
50
        return $this->token === 'J_STRING_LITERAL';
51
    }
52
53
    public function isTranslationFunction() : bool
54
    {
55
        return $this->isVariableOrFunction() && isset($this->nameLookup[$this->getValue()]);
56
    }
57
    
58
    public function isVariableOrFunction() : bool
59
    {
60
        return $this->token === 'J_IDENTIFIER' || $this->token === 'J_FUNCTION';
61
    }
62
63
    public function isExplanationFunction() : bool
64
    {
65
        return false;
66
    }
67
68
    public function isArgumentSeparator() : bool
69
    {
70
        return $this->getToken() === ',';
71
    }
72
}
73