Completed
Push — master ( a58136...765db2 )
by Siro Díaz
02:24
created

TrieTreeTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 29.17 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 7
loc 24
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testAdd() 7 7 1
A testWordCount() 0 8 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
use PHPUnit\Framework\TestCase;
4
use DataStructures\Trees\TrieTree;
5
6
7
class TrieTreeTest extends TestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
    private $tree;
9
10
    public function setUp() {
11
        $this->tree = new TrieTree();
12
    }
13
14 View Code Duplication
    public function testAdd() {
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...
15
        $this->tree->add('hello');
16
        $this->tree->add('bye');
17
        $this->assertEquals(8, $this->tree->size());
18
        $this->tree->add('hello');
19
        $this->assertEquals(8, $this->tree->size());
20
    }
21
22
    public function testWordCount() {
23
        $this->tree->add('hello');
24
        $this->assertEquals(1, $this->tree->wordCount());
25
        $this->tree->add('bye');
26
        $this->assertEquals(2, $this->tree->wordCount());
27
        $this->tree->add('hello');
28
        $this->assertEquals(2, $this->tree->wordCount());
29
    }
30
}