BasePHPVisitor   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 20
ccs 8
cts 9
cp 0.8889
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStringArgument() 0 17 4
1
<?php
2
3
/*
4
 * This file is part of the PHP Translation package.
5
 *
6
 * (c) PHP Translation team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Translation\Extractor\Visitor\Php;
13
14
use PhpParser\Node;
15
use Translation\Extractor\Visitor\BaseVisitor;
16
17
/**
18
 * Base class for PHP visitors.
19
 *
20
 * @author Tobias Nyholm <[email protected]>
21
 */
22
abstract class BasePHPVisitor extends BaseVisitor
23
{
24 9
    protected function getStringArgument(Node\Expr\MethodCall $node, int $index): ?string
25
    {
26 9
        if (!isset($node->args[$index])) {
27 6
            return null;
28
        }
29
30 9
        if (!$node->args[$index]->value instanceof Node\Scalar\String_) {
31 6
            return null;
32
        }
33
34 9
        $label = $node->args[$index]->value->value;
35 9
        if (empty($label)) {
36
            return null;
37
        }
38
39 9
        return $label;
40
    }
41
}
42