IG19286Test   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 2
Dependencies 5

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 13 13 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\IG19286Test: 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\Subgraph;
29
30
require 'vendor/autoload.php';
31
32
/**
33
 * A recreation of Image_GraphViz bug_19286.phpt
34
 *
35
 * Image_GraphViz version author: Frédéric G. Marand <[email protected]>
36
 *
37
 * Request 19286: "Loop error on empty clusters."
38
 *
39
 * @link     http://pear.php.net/bugs/bug.php?id=19286
40
 */
41 View Code Duplication
class IG19286Test 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
  subgraph s1_id {
49
    label=s1_title;
50
  } /* /subgraph s1_id */
51
} /* /digraph G */
52
53
EOT;
54
55
  public function setUp() : void {
56
    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...
57
    $g = $this->Graph;
58
    $dic = $this->dic;
59
    $g->setDirected(true);
60
61
    $g->addChild($c1_id = new Cluster($dic, 'c1_id', array(
62
      new Attribute($dic, 'label', 'c1_title'),
63
    )));
64
    $g->addChild($s1_id = new Subgraph($dic, 's1_id', array(
65
      new Attribute($dic, 'label', 's1_title'),
66
    )));
67
  }
68
69
  /**
70
   * Tests Graph->build()
71
   */
72
  public function testBuild() {
73
    $this->check($this->expected, "Image_GraphViz bug test 19286 passed.");
74
  }
75
}
76