Choice.php
1.33 KB
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
namespace FootyRoom\Core\Poll;
use FootyRoom\Core\CoreException;
/**
* Choice value object.
*/
class Choice
{
/**
* @var int Id of this choice, uniqie within the poll only
*/
protected $id;
/**
* @var string Text value representing this choice
*/
protected $text;
/**
* @var string URL to the image representing this choice
*/
protected $image;
/**
* Constructor.
*
* @param int $id
* @param string $text
* @param string $image
*
* @throws \FootyRoom\Core\CoreException
*/
public function __construct($id, $text, $image)
{
$this->id = $id;
$this->text = $text;
$this->image = $image;
if (!strlen($this->text) && !strlen($this->image)) {
throw new CoreException('Either text or image of a choice must be set.');
}
}
/**
* Gets the value of id.
*
* @return int id of this choice of poll.
*/
public function getId()
{
return $this->id;
}
/**
* Gets the value of text.
*
* @return string|int
*/
public function getText()
{
return $this->text;
}
/**
* Gets the value of image.
*
* @return string
*/
public function getImage()
{
return $this->image;
}
}