Completed
Push — feature/EVO-7277-schema-title ( 0eb4b8 )
by
unknown
66:17
created

FieldTitleMapperTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testMap() 13 13 1
A mapData() 9 9 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
 * validate mapping of names to singular
4
 */
5
6
namespace Graviton\GeneratorBundle\Tests\Generator\ResourceGenerator;
7
8
use \Graviton\GeneratorBundle\Generator\ResourceGenerator\FieldTitleMapper;
9
10
/**
11
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
12
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
13
 * @link     http://swisscom.ch
14
 */
15 View Code Duplication
class FieldTitleMapperTest extends \PHPUnit_Framework_TestCase
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...
16
{
17
    /**
18
     * @dataProvider mapData
19
     *
20
     * @param string $field    field form of string
21
     * @param string $expected expected form of string
22
     *
23
     * @return void
24
     */
25
    public function testMap($field, $expected)
26
    {
27
        $sut = new FieldTitleMapper;
28
29
        $field = [
30
            'fieldName' => $field
31
        ];
32
        $expected = [
33
            'fieldName' => $field,
34
            'title' => $expected
35
        ];
36
        $this->assertEquals($expected, $sut->map($field));
37
    }
38
39
    /**
40
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use string[][].

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
41
     */
42
    public function mapData()
43
    {
44
        return [
45
            ['names', 'Names'],
46
            [' buses', 'Buses'],
47
            ['buses.are.cool', 'Buses Are Cool'],
48
            ['bus.0.name', 'Bus Array Name'],
49
        ];
50
    }
51
}
52