IG18676Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 2
cbo 5
dl 30
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 11 11 1
A testBuild() 3 3 1

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
/**
4
 * @file
5
 * Grafizzi\Graph\Tests\IG18676Test: a component of the Grafizzi library.
6
 *
7
 * (c) 2012 Frédéric G. MARAND <[email protected]>
8
 *
9
 * Grafizzi is free software: you can redistribute it and/or modify it under the
10
 * terms of the GNU Lesser General Public License as published by the Free
11
 * Software Foundation, either version 3 of the License, or (at your option) any
12
 * later version.
13
 *
14
 * Grafizzi is distributed in the hope that it will be useful, but WITHOUT ANY
15
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
 * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
17
 * details.
18
 *
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with Grafizzi, in the COPYING.LESSER.txt file.  If not, see
21
 * <http://www.gnu.org/licenses/>
22
 */
23
24
namespace Grafizzi\Graph\Tests;
25
26
use Grafizzi\Graph\Attribute;
27
use Grafizzi\Graph\Cluster;
28
use Grafizzi\Graph\Node;
29
30
require 'vendor/autoload.php';
31
32
/**
33
 * A recreation of Image_GraphViz bug_18676.phpt
34
 *
35
 * Image_GraphViz version author: Frédéric G. Marand <[email protected]>
36
 *
37
 * Request 18676: "Cluster doesn't show if there's no nodes inside."
38
 *
39
 * @link     http://pear.php.net/bugs/bug.php?id=18676
40
 */
41 View Code Duplication
class IG18676Test extends BaseGraphTest {
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...
42
43
  public $expected = <<<EOT
44
strict digraph G {
45
  subgraph cluster_c1_id {
46
    label=c1_title;
47
  } /* /subgraph cluster_c1_id */
48
} /* /digraph G */
49
50
EOT;
51
52
  public function setUp() : void {
53
    parent::setUpExtended('G', array('strict' => true));
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setUpExtended() instead of setUp()). Are you sure this is correct? If so, you might want to change this to $this->setUpExtended().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
54
    $g = $this->Graph;
55
    $dic = $this->dic;
56
    $g->setDirected(true);
57
58
    $g->addChild($cluster = new Cluster($dic, 'c1_id', array(
59
      new Attribute($dic, 'label', 'c1_title'),
60
    )));
61
    $cluster->addChild(new Node($dic, 'n', array('implicit' => true)));
62
  }
63
64
  /**
65
   * Tests Graph->build()
66
   */
67
  public function testBuild() {
68
    $this->check($this->expected, "Image_GraphViz bug test 18676 passed.");
69
  }
70
}
71