MeaninglessMethodName::apply()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 10
ccs 8
cts 8
cp 1
rs 9.4285
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
namespace MS\PHPMD\Rule\CleanCode;
4
5
use PHPMD\AbstractNode;
6
use PHPMD\AbstractRule;
7
use PHPMD\Node\MethodNode;
8
use PHPMD\Rule\MethodAware;
9
10
/**
11
 * Class MeaninglessMethodName
12
 *
13
 * Try to avoid meaningless method names. You or other developers don't understand what the method does in a few month.
14
 *
15
 * @package MS\PHPMD\Rule\CleanCode
16
 */
17
class MeaninglessMethodName extends AbstractRule implements MethodAware
18
{
19
    /**
20
     * @param AbstractNode|MethodNode $node
21
     */
22 2
    public function apply(AbstractNode $node)
23
    {
24 2
        $meaninglessNames = $this->getStringProperty('meaninglessNames');
25 2
        $delimiter = $this->getStringProperty('delimiter');
26 2
        $methodName = $node->getImage();
27
28 2
        if (in_array(strtolower($methodName), explode($delimiter, strtolower($meaninglessNames)))) {
29 1
            $this->addViolation($node, [$methodName, $meaninglessNames]);
30 1
        }
31 2
    }
32
}
33