TypeHintFeature   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fix() 0 14 3
1
<?php
2
declare (strict_types = 1);
3
4
namespace JanPiet\PhpTranspiler\Feature;
5
6
use JanPiet\PhpTranspiler\NodeSearch;
7
use PhpParser\Node;
8
9
class TypeHintFeature implements FeatureInterface
10
{
11
    private $php7OnlyTypeHints = ['int', 'string', 'float', 'bool'];
12
13
    /**
14
     * @param NodeSearch $nodeSearch
15
     * @return bool
16
     */
17 6
    public function fix(NodeSearch $nodeSearch): bool
18
    {
19 6
        $found = false;
20 6
        foreach ($nodeSearch->eachType(Node\Param::class) as $node) {
21 6
            if (!in_array($node->type, $this->php7OnlyTypeHints)) {
22 4
                continue;
23
            }
24
25 5
            $found = true;
26 5
            $node->type = null;
27
        }
28
29 6
        return $found;
30
    }
31
}
32