Completed
Push — master ( 3f6f4c...500d6b )
by Enrico
10s
created

DoNotUseInlineHTML   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 54.55%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 37
ccs 6
cts 11
cp 0.5455
rs 10
c 1
b 0
f 0
wmc 3
lcom 0
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 6 1
A getConfiguration() 0 9 1
A getRegister() 0 6 1
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 DoNotUseInlineHTML implements Pass\ConfigurablePassInterface, Pass\AnalyzerPassInterface
12
{
13
    /**
14
     * @param Stmt\InlineHTML $stmt
15
     * @param Context $context
16
     * @return bool
17
     */
18 1
    public function pass(Stmt\InlineHTML $stmt, Context $context)
19
    {
20 1
        $context->notice('do_not_use_inline_html', 'Do not use inline HTML', $stmt);
21
22 1
        return true;
23
    }
24
25
    /**
26
     * @return TreeBuilder
27
     */
28
    public function getConfiguration()
29
    {
30
        $treeBuilder = new TreeBuilder();
31
        $treeBuilder->root('do_not_use_inline_html')
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\InlineHTML::class,
45 1
        ];
46
    }
47
}
48