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

ExitUsage::pass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
c 1
b 0
f 0
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