Event::getEnd()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of CalendR, a Fréquence web project.
5
 *
6
 * (c) 2012 Fréquence web
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace CalendR\Event;
13
14
/**
15
 * Concrete implementation of AbstractEvent and in fact EventInterface.
16
 *
17
 * In most case, you'd better to implement your own events
18
 *
19
 * @author Yohan Giarelli <[email protected]>
20
 */
21
class Event extends AbstractEvent
22
{
23
    /**
24
     * @var \DateTime
25
     */
26
    protected $begin;
27
28
    /**
29
     * @var \DateTime
30
     */
31
    protected $end;
32
33
    /**
34
     * @var string
35
     */
36
    protected $uid;
37
38
    public function __construct($uid, \DateTime $start, \DateTime $end)
39
    {
40
        if ($start->diff($end)->invert == 1) {
41
            throw new \InvalidArgumentException('Events usually start before they end');
42
        }
43
44
        $this->uid = $uid;
45
        $this->begin = clone $start;
46
        $this->end = clone $end;
47
    }
48
49
    /**
50
     * Returns an unique identifier for the Event.
51
     * Could be any string, but MUST to be unique.
52
     *   ex : 'event-8', 'meeting-43'.
53
     *
54
     * @return string an unique event identifier
55
     */
56
    public function getUid()
57
    {
58
        return $this->uid;
59
    }
60
61
    /**
62
     * Returns the event begin.
63
     *
64
     * @return \DateTime event begin
65
     */
66
    public function getBegin()
67
    {
68
        return $this->begin;
69
    }
70
71
    /**
72
     * Returns the event end.
73
     *
74
     * @return \DateTime event end
75
     */
76
    public function getEnd()
77
    {
78
        return $this->end;
79
    }
80
}
81