Completed
Push — master ( 2a0a89...468a99 )
by Christian
02:41
created

SunTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 40.91 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 1
dl 18
loc 44
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A givenThereIsASunObject() 0 4 1
A testSunSetBeforeSunRiseException() 0 7 1
A testSunRise() 9 9 1
A testSunSet() 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
 * Copyright Zikula Foundation 2014 - Zikula Application Framework
4
 *
5
 * This work is contributed to the Zikula Foundation under one or more
6
 * Contributor Agreements and licensed to You under the following license:
7
 *
8
 * @license GNU/LGPv3 (or at your option any later version).
9
 * @package OpenWeatherMap-PHP-Api
10
 *
11
 * Please see the NOTICE file distributed with this source code for further
12
 * information regarding copyright and licensing.
13
 */
14
15
namespace Cmfcmf\OpenWeatherMap\Tests\Util;
16
17
use Cmfcmf\OpenWeatherMap\Util\Sun;
18
19
class SunTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var Sun
23
     */
24
    private $sun;
25
26 View Code Duplication
    public function testSunRise()
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...
27
    {
28
        $rise = new \DateTime('2014-01-01 08:00:00');
29
        $set = new \DateTime('2014-01-01 20:00:00');
30
31
        $this->givenThereIsASunObject($rise, $set);
32
33
        $this->assertSame($rise, $this->sun->rise);
34
    }
35
36 View Code Duplication
    public function testSunSet()
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...
37
    {
38
        $rise = new \DateTime('2014-01-01 08:00:00');
39
        $set = new \DateTime('2014-01-01 20:00:00');
40
41
        $this->givenThereIsASunObject($rise, $set);
42
43
        $this->assertSame($set, $this->sun->set);
44
    }
45
46
47
    private function givenThereIsASunObject($rise, $set)
48
    {
49
        $this->sun = new Sun($rise, $set);
50
    }
51
52
    /**
53
     * @expectedException \LogicException
54
     */
55
    public function testSunSetBeforeSunRiseException()
56
    {
57
        $rise = new \DateTime('2014-01-01 08:00:00');
58
        $set = new \DateTime('2014-01-01 7:00:00');
59
60
        $this->givenThereIsASunObject($rise, $set);
61
    }
62
}
63