Completed
Pull Request — master (#179)
by
unknown
03:48
created

DoNotUseLabels::getRegister()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Statement;
4
5
use PhpParser\Node\Stmt;
6
use PhpParser\Node;
7
use PHPSA\Analyzer\Pass;
8
use PHPSA\Context;
9
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
10
11
class DoNotUseLabels implements Pass\ConfigurablePassInterface, Pass\AnalyzerPassInterface
12
{
13
    /**
14
     * @param Stmt\Label $stmt
15
     * @param Context $context
16
     * @return bool
17
     */
18 2
    public function pass(Stmt\Label $stmt, Context $context)
19
    {
20 2
        $context->notice('do_not_use_labels', 'Do not use labels', $stmt);
21
22 2
        return true;
23
    }
24
25
    /**
26
     * @return TreeBuilder
27
     */
28
    public function getConfiguration()
29
    {
30
        $treeBuilder = new TreeBuilder();
31
        $treeBuilder->root('do_not_use_labels')
32
            ->canBeDisabled()
33
        ;
34
35
        return $treeBuilder;
36
    }
37
38
    /**
39
     * @return array
40
     */
41 1
    public function getRegister()
42
    {
43
        return [
44 1
            Stmt\Goto_::class,
45 1
            Stmt\Label::class,
46 1
        ];
47
    }
48
}
49