CouplingBetweenObjects::apply()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 2
1
<?php
2
/**
3
 * This file is part of PHP Mess Detector.
4
 *
5
 * Copyright (c) Manuel Pichler <[email protected]>.
6
 * All rights reserved.
7
 *
8
 * Licensed under BSD License
9
 * For full copyright and license information, please see the LICENSE file.
10
 * Redistributions of files must retain the above copyright notice.
11
 *
12
 * @author Manuel Pichler <[email protected]>
13
 * @copyright Manuel Pichler. All rights reserved.
14
 * @license https://opensource.org/licenses/bsd-license.php BSD License
15
 * @link http://phpmd.org/
16
 */
17
18
namespace PHPMD\Rule\Design;
19
20
use PHPMD\AbstractNode;
21
use PHPMD\AbstractRule;
22
use PHPMD\Rule\ClassAware;
23
24
/**
25
 * This rule class detects violations of Coupling Between Objects metric.
26
 *
27
 * @since      1.1.0
28
 */
29
class CouplingBetweenObjects extends AbstractRule implements ClassAware
30
{
31
    /**
32
     * This method should implement the violation analysis algorithm of concrete
33
     * rule implementations. All extending classes must implement this method.
34
     *
35
     * @param \PHPMD\AbstractNode $node
36
     * @return void
37
     */
38 4
    public function apply(AbstractNode $node)
39
    {
40 4
        $cbo = $node->getMetric('cbo');
41 4
        if ($cbo >= ($threshold = $this->getIntProperty('maximum'))) {
42 3
            $this->addViolation($node, array($node->getName(), $cbo, $threshold));
43
        }
44 4
    }
45
}
46