CheckLNumberKind   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A pass() 0 13 2
A getRegister() 0 6 1
1
<?php
2
3
namespace PHPSA\Analyzer\Pass\Scalar;
4
5
use PhpParser\Node\Scalar;
6
use PHPSA\Analyzer\Helper\DefaultMetadataPassTrait;
7
use PHPSA\Analyzer\Pass\AnalyzerPassInterface;
8
use PHPSA\Context;
9
10
class CheckLNumberKind implements AnalyzerPassInterface
11
{
12
    use DefaultMetadataPassTrait;
13
14
    const DESCRIPTION = 'Using octal, hexadecimal or binary integers is discouraged.';
15
16
    /**
17
     * @param Scalar\LNumber $lNum
18
     * @param Context $context
19
     * @return bool
20
     */
21
    public function pass(Scalar\LNumber $lNum, Context $context)
22
    {
23
        if ($lNum->getAttribute('kind') != Scalar\LNumber::KIND_DEC) {
24
            $context->notice(
25
                'l_number_kind',
26
                'Avoid using octal, hexadecimal or binary',
27
                $lNum
28
            );
29
            return true;
30
        }
31
32
        return false;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getRegister()
39
    {
40
        return [
41
            Scalar\LNumber::class,
42
        ];
43
    }
44
}
45