GotoStatement   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 16
loc 16
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 6 6 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\FunctionAware;
23
use PHPMD\Rule\MethodAware;
24
25
/**
26
 * This rule class detects the usage of PHP's goto statement.
27
 *
28
 * @since      1.1.0
29
 */
30 View Code Duplication
class GotoStatement extends AbstractRule implements MethodAware, FunctionAware
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
{
32
    /**
33
     * This method should implement the violation analysis algorithm of concrete
34
     * rule implementations. All extending classes must implement this method.
35
     *
36
     * @param \PHPMD\AbstractNode $node
37
     * @return void
38
     */
39 6
    public function apply(AbstractNode $node)
40
    {
41 6
        foreach ($node->findChildrenOfType('GotoStatement') as $goto) {
42 3
            $this->addViolation($goto, array($node->getType(), $node->getName()));
43
        }
44 6
    }
45
}
46