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

Sun   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 0
cbo 0
dl 0
loc 30
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
1
<?php
2
/**
3
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4
 *
5
 * @license MIT
6
 *
7
 * Please see the LICENSE file distributed with this source code for further
8
 * information regarding copyright and licensing.
9
 *
10
 * Please visit the following links to read about the usage policies and the license of
11
 * OpenWeatherMap before using this class:
12
 *
13
 * @see http://www.OpenWeatherMap.org
14
 * @see http://www.OpenWeatherMap.org/terms
15
 * @see http://openweathermap.org/appid
16
 */
17
18
namespace Cmfcmf\OpenWeatherMap\Util;
19
20
/**
21
 * The sun class representing a sun object.
22
 */
23
class Sun
24
{
25
    /**
26
     * @var \DateTime The time of the sun rise.
27
     */
28
    public $rise;
29
30
    /**
31
     * @var \DateTime The time of the sun set.
32
     */
33
    public $set;
34
35
    /**
36
     * Create a new sun object.
37
     *
38
     * @param \DateTime $rise The time of the sun rise
39
     * @param \DateTime $set  The time of the sun set.
40
     *
41
     * @throws \LogicException If sunset is before sunrise.
42
     * @internal
43
     */
44 3
    public function __construct(\DateTime $rise, \DateTime $set)
45
    {
46 3
        if ($set < $rise) {
47 1
            throw new \LogicException('Sunset cannot be before sunrise!');
48
        }
49 2
        $this->rise = $rise;
50 2
        $this->set = $set;
51 2
    }
52
}
53