Completed
Push — master ( 7a3cb1...e42624 )
by Harry
9s
created

DateTimeProcessorTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 66.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testDateTimeFormat() 8 8 1
A testCustomFormat() 8 8 1
A testIgnoreNonDateTimes() 0 6 1
A testInvoke() 8 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
 * This file is part of graze/data-file
4
 *
5
 * Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license https://github.com/graze/data-file/blob/master/LICENSE.md
11
 * @link    https://github.com/graze/data-file
12
 */
13
14
namespace Graze\DataFile\Test\Unit\Format\Processor;
15
16
use DateTime;
17
use Graze\DataFile\Format\Processor\DateTimeProcessor;
18
use Graze\DataFile\Test\TestCase;
19
20
class DateTimeProcessorTest extends TestCase
21
{
22 View Code Duplication
    public function testDateTimeFormat()
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...
23
    {
24
        $processor = new DateTimeProcessor();
25
26
        $date = new DateTime();
27
28
        static::assertEquals([$date->format('Y-m-d H:i:s')], $processor->process([$date]));
29
    }
30
31 View Code Duplication
    public function testCustomFormat()
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...
32
    {
33
        $processor = new DateTimeProcessor('Y-m-d');
34
35
        $date = new DateTime();
36
37
        static::assertEquals([$date->format('Y-m-d')], $processor->process([$date]));
38
    }
39
40
    public function testIgnoreNonDateTimes()
41
    {
42
        $processor = new DateTimeProcessor('Y-m-d');
43
44
        static::assertEquals(['stirng', 1, 2.5, false, null], $processor->process(['stirng', 1, 2.5, false, null]));
45
    }
46
47 View Code Duplication
    public function testInvoke()
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
        $processor = new DateTimeProcessor();
50
51
        $date = new DateTime();
52
53
        static::assertEquals([$date->format('Y-m-d H:i:s')], $processor([$date]));
54
    }
55
}
56