CreateTokenCollectionUnitTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 11.11 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUpCollection() 0 4 1
A getColumnList() 0 7 1
A getPlaceholderList() 7 7 1
A getBindingsList() 0 11 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 Hgraca\MicroDbal\Test\Crud\QueryBuilder\Sql;
4
5
use Hgraca\MicroDbal\Crud\QueryBuilder\Sql\CreateToken;
6
use Hgraca\MicroDbal\Crud\QueryBuilder\Sql\CreateTokenCollection;
7
use PHPUnit_Framework_TestCase;
8
9
final class CreateTokenCollectionUnitTest extends PHPUnit_Framework_TestCase
10
{
11
    /** @var array */
12
    private $dataSet = [
13
        'id' => 1,
14
        'dummy_column_1' => 'some text',
15
        'dummy_column_2' => null,
16
    ];
17
18
    /** @var CreateTokenCollection */
19
    private $createTokenCollection;
20
21
    /**
22
     * @before
23
     */
24
    public function setUpCollection()
25
    {
26
        $this->createTokenCollection = new CreateTokenCollection($this->dataSet);
27
    }
28
29
    /**
30
     * @test
31
     *
32
     * @small
33
     */
34
    public function getColumnList()
35
    {
36
        self::assertEquals(
37
            '(`id`, `dummy_column_1`, `dummy_column_2`)',
38
            $this->createTokenCollection->getColumnList()
39
        );
40
    }
41
42
    /**
43
     * @test
44
     *
45
     * @small
46
     */
47 View Code Duplication
    public function getPlaceholderList()
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...
48
    {
49
        self::assertEquals(
50
            '(' . CreateToken::BINDING_PREFIX . '0, ' . CreateToken::BINDING_PREFIX . '1, ' . CreateToken::BINDING_PREFIX . '2)',
51
            $this->createTokenCollection->getPlaceholderList()
52
        );
53
    }
54
55
    /**
56
     * @test
57
     *
58
     * @small
59
     */
60
    public function getBindingsList()
61
    {
62
        self::assertEquals(
63
            [
64
                ':c0' => 1,
65
                ':c1' => 'some text',
66
                ':c2' => null,
67
            ],
68
            $this->createTokenCollection->getBindingsList()
69
        );
70
    }
71
}
72