CreateTokenCollectionCollectionUnitTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 77
Duplicated Lines 9.09 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 7
loc 77
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 18 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\CreateTokenCollectionCollection;
7
use PHPUnit_Framework_TestCase;
8
9
final class CreateTokenCollectionCollectionUnitTest extends PHPUnit_Framework_TestCase
10
{
11
    /** @var array */
12
    private $dataSet = [
13
        [
14
            'id' => 1,
15
            'dummy_column_1' => 'some text',
16
            'dummy_column_2' => null,
17
        ],
18
        [
19
            'id' => 2,
20
            'dummy_column_1' => 'some other text',
21
            'dummy_column_2' => 7,
22
        ],
23
    ];
24
25
    /** @var CreateTokenCollectionCollection */
26
    private $createTokenCollection;
27
28
    /**
29
     * @before
30
     */
31
    public function setUpCollection()
32
    {
33
        $this->createTokenCollection = new CreateTokenCollectionCollection($this->dataSet);
34
    }
35
36
    /**
37
     * @test
38
     *
39
     * @small
40
     */
41
    public function getColumnList()
42
    {
43
        self::assertEquals(
44
            '(`id`, `dummy_column_1`, `dummy_column_2`)',
45
            $this->createTokenCollection->getColumnList()
46
        );
47
    }
48
49
    /**
50
     * @test
51
     *
52
     * @small
53
     */
54 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...
55
    {
56
        self::assertEquals(
57
            '(' . CreateToken::BINDING_PREFIX . '0, ' . CreateToken::BINDING_PREFIX . '1, ' . CreateToken::BINDING_PREFIX . '2)',
58
            $this->createTokenCollection->getPlaceholderList()
59
        );
60
    }
61
62
    /**
63
     * @test
64
     *
65
     * @small
66
     */
67
    public function getBindingsList()
68
    {
69
        self::assertEquals(
70
            [
71
                [
72
                    ':c0' => 1,
73
                    ':c1' => 'some text',
74
                    ':c2' => null,
75
                ],
76
                [
77
                    ':c0' => 2,
78
                    ':c1' => 'some other text',
79
                    ':c2' => 7,
80
                ],
81
            ],
82
            $this->createTokenCollection->getBindingsList()
83
        );
84
    }
85
}
86