Completed
Pull Request — master (#228)
by Kévin
06:35
created

ExitUsage   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 28
ccs 9
cts 9
cp 1
rs 10
c 1
b 0
f 0
wmc 2
lcom 0
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 10 1
A getRegister() 0 6 1
1
<?php
2
/**
3
 * @author Kévin Gomez https://github.com/K-Phoen <[email protected]>
4
 */
5
6
namespace PHPSA\Analyzer\Pass\Expression;
7
8
use PhpParser\Node\Expr;
9
use PHPSA\Analyzer\Pass;
10
use PHPSA\Context;
11
12
class ExitUsage implements Pass\AnalyzerPassInterface
13
{
14
    /**
15
     * @param Expr\Exit_ $expr
16
     * @param Context $context
17
     * @return bool
18
     */
19 2
    public function pass(Expr\Exit_ $expr, Context $context)
20
    {
21 2
        $context->notice(
22 2
            'exit_usage',
23 2
            'exit/die statements make the code hard to test and should not be used',
24
            $expr
25 2
        );
26
27 2
        return true;
28
    }
29
30
    /**
31
     * @return array
32
     */
33 1
    public function getRegister()
34
    {
35
        return [
36 1
            Expr\Exit_::class,
37 1
        ];
38
    }
39
}
40