1: <?php
2: /**
3: * This file is part of the FastFeed package.
4: *
5: * (c) Daniel González <daniel@desarrolla2.com>
6: *
7: * For the full copyright and license information, please view the LICENSE
8: * file that was distributed with this source code.
9: */
10: namespace FastFeed;
11:
12: use DateTime;
13:
14: /**
15: * Node
16: */
17: class Item
18: {
19: /**
20: * @var string
21: */
22: protected $itemId;
23:
24: /**
25: * @var string
26: */
27: protected $name;
28:
29: /**
30: * @var string
31: */
32: protected $intro;
33:
34: /**
35: * @var string
36: */
37: protected $content;
38:
39: /**
40: * @var string
41: */
42: protected $source;
43:
44: /**
45: * @var string
46: */
47: protected $author;
48:
49: /**
50: * @var string
51: */
52: protected $image;
53:
54: /**
55: * @var DateTime
56: */
57: protected $date;
58:
59: /**
60: * @var array
61: */
62: protected $extra = array();
63:
64: /**
65: * @var array
66: */
67: protected $tags = array();
68:
69: /**
70: * @param string $itemId
71: */
72: public function setId($itemId)
73: {
74: $this->itemId = (string) $itemId;
75: }
76:
77: /**
78: * @return string
79: */
80: public function getId()
81: {
82: return $this->itemId;
83: }
84:
85: /**
86: * @return string
87: */
88: public function getContent()
89: {
90: return $this->content;
91: }
92:
93: /**
94: * @param string $name
95: */
96: public function setName($name)
97: {
98: $this->name = (string) $name;
99: }
100:
101: /**
102: * @param string $intro
103: */
104: public function setIntro($intro)
105: {
106: $this->intro = (string) $intro;
107: }
108:
109: /**
110: * @return string
111: */
112: public function getIntro()
113: {
114: return $this->intro;
115: }
116:
117: /**
118: * @param string $content
119: */
120: public function setContent($content)
121: {
122: $this->content = (string) $content;
123: }
124:
125: /**
126: * @return string
127: */
128: public function getName()
129: {
130: return $this->name;
131: }
132:
133: /**
134: * @return bool
135: */
136: public function hasImage()
137: {
138: return strlen($this->image) ? true : false;
139: }
140:
141: /**
142: * @param string $image
143: */
144: public function setImage($image)
145: {
146: $this->image = (string) $image;
147: }
148:
149: /**
150: * @return string
151: */
152: public function getImage()
153: {
154: return $this->image;
155: }
156:
157: /**
158: * @param string $tag
159: */
160: public function addTag($tag)
161: {
162: $this->tags[] = (string) $tag;
163: }
164:
165: /**
166: * @param array $tags
167: */
168: public function setTags(array $tags)
169: {
170: $this->tags = array();
171: foreach ($tags as $tag) {
172: $this->addTag($tag);
173: }
174: }
175:
176: /**
177: * @return array
178: */
179: public function getTags()
180: {
181: return $this->tags;
182: }
183:
184: /**
185: * @param string $source
186: */
187: public function setSource($source)
188: {
189: $this->source = (string) $source;
190: }
191:
192: /**
193: * @return string
194: */
195: public function getSource()
196: {
197: return $this->source;
198: }
199:
200: /**
201: * @param string $author
202: */
203: public function setAuthor($author)
204: {
205: $this->author = (string) $author;
206: }
207:
208: /**
209: * @return string
210: */
211: public function getAuthor()
212: {
213: return $this->author;
214: }
215:
216: /**
217: * @param DateTime $date
218: */
219: public function setDate(DateTime $date)
220: {
221: $this->date = $date;
222: }
223:
224: /**
225: * @return DateTime
226: */
227: public function getDate()
228: {
229: if (!$this->date) {
230: return false;
231: }
232:
233: return $this->date;
234: }
235:
236: /**
237: * @param $key
238: * @param $value
239: */
240: public function setExtra($key, $value)
241: {
242: $this->extra[$key] = $value;
243: }
244:
245: /**
246: * @param $key
247: *
248: * @return bool
249: */
250: public function getExtra($key)
251: {
252: if (!isset($this->extra[$key])) {
253: return;
254: }
255:
256: return $this->extra[$key];
257: }
258: }
259: