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

Sun::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4286
cc 2
eloc 5
nc 2
nop 2
crap 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