-
Notifications
You must be signed in to change notification settings - Fork 27
/
view.php
76 lines (63 loc) · 1.5 KB
/
view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
ini_set('date.timezone', 'America/Toronto');
date_default_timezone_set('America/Toronto');
class Ticket
{
const SOON = 1;
const EARLY = 2;
const OPEN = 3;
const OVER = 4;
private $earlyStart;
private $earlyEnd;
private $salesEnd;
private $earlyPrice;
private $regularPrice;
public function __construct(DateTime $earlyStart, DateTime $earlyEnd, DateTime $salesEnd, $earlyPrice, $regularPrice)
{
$this->earlyStart = $earlyStart;
$this->earlyEnd = $earlyEnd;
$this->salesEnd = $salesEnd;
$this->earlyPrice = $earlyPrice;
$this->regularPrice = $regularPrice;
}
public function getSaleState()
{
$today = new DateTime;
if ($today < $this->earlyStart) {
return $this::SOON;
}
if ($today < $this->earlyEnd) {
return $this::EARLY;
}
if ($today < $this->salesEnd) {
return $this::OPEN;
}
return $this::OVER;
}
public function getEarlyPrice()
{
return $this->earlyPrice;
}
public function getRegularPrice()
{
return $this->regularPrice;
}
public function getEarlyEnd()
{
return $this->earlyEnd;
}
}
class View
{
}
$view = new View;
$view->ticket = new Ticket(
new DateTime('2016-08-15'),
new DateTime('2016-10-01'),
new DateTime('2016-11-07'),
250,
300
);
$view->cfpOpen = false;
$view->speakersAnnounced = true;
$view->scheduleAnnounced = true;