ColorsAdapterTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 77.78 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 3
dl 14
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testColorAdapter() 7 7 1
A testStringIsReturnedAsIsIfNoStyleExists() 7 7 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
namespace PhpSchool\PSXTest;
4
5
use Colors\Color;
6
use PhpSchool\PSX\ColorsAdapter;
7
use PHPUnit_Framework_TestCase;
8
9
/**
10
 * Class ColorsAdapterTest
11
 * @package PhpSchool\PSXTest
12
 * @author Aydin Hassan <[email protected]>
13
 */
14
class ColorsAdapterTest extends PHPUnit_Framework_TestCase
15
{
16 View Code Duplication
    public function testColorAdapter()
0 ignored issues
show
Duplication introduced by
This method 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...
17
    {
18
        $color = new Color;
19
        $color->setForceStyle(true);
20
        $adapter = new ColorsAdapter($color);
21
        $this->assertSame('HELLO WORLD', $adapter->colour('HELLO WORLD', 'green'));
22
    }
23
24 View Code Duplication
    public function testStringIsReturnedAsIsIfNoStyleExists()
0 ignored issues
show
Duplication introduced by
This method 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...
25
    {
26
        $color = new Color;
27
        $color->setForceStyle(true);
28
        $adapter = new ColorsAdapter($color);
29
        $this->assertSame('HELLO WORLD', $adapter->colour('HELLO WORLD', 'not-a-style'));
30
    }
31
}
32