Entry.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. /**
  3. *
  4. * Cube Framework $Id$ QALpM3u7lqOMsgICJPtyCKg4/tcBXUah4q0viZK6e3Y=
  5. *
  6. * @link http://codecu.be/framework
  7. * @copyright Copyright (c) 2014 CodeCube SRL
  8. * @license http://codecu.be/framework/license Commercial License
  9. *
  10. * @version 1.3
  11. */
  12. /**
  13. * abstract feed class
  14. */
  15. namespace Cube\Feed;
  16. class Entry
  17. {
  18. /**
  19. *
  20. * elements array
  21. *
  22. * @var array
  23. */
  24. protected $_elements = array();
  25. /**
  26. *
  27. * set elements
  28. *
  29. * @param array $elements
  30. *
  31. * @return $this
  32. */
  33. public function setElements($elements)
  34. {
  35. foreach ((array)$elements as $key => $value) {
  36. $this->addElement($key, $value);
  37. }
  38. return $this;
  39. }
  40. /**
  41. *
  42. * add single element to elements array
  43. *
  44. * @param string $key
  45. * @param string $value
  46. *
  47. * @return $this
  48. */
  49. public function addElement($key, $value)
  50. {
  51. $this->_elements[$key] = $this->_formatString($value);
  52. return $this;
  53. }
  54. /**
  55. *
  56. * get elements array
  57. *
  58. * @return array
  59. */
  60. public function getElements()
  61. {
  62. return $this->_elements;
  63. }
  64. /**
  65. *
  66. * clear elements array
  67. *
  68. * @return $this
  69. */
  70. public function clearElements()
  71. {
  72. $this->_elements = array();
  73. return $this;
  74. }
  75. /**
  76. *
  77. * format string
  78. *
  79. * @param string $string
  80. *
  81. * @return string
  82. */
  83. protected function _formatString($string)
  84. {
  85. return strip_tags(
  86. str_ireplace(
  87. array('&'), array('&amp;'), $string));
  88. }
  89. }