You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuMultipleDbo.php 998B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Luticate\Utils;
  3. class LuMultipleDbo implements \JsonSerializable {
  4. /**
  5. * @var int
  6. */
  7. private $_count;
  8. public function setCount($count)
  9. {
  10. $this->_count = $count;
  11. }
  12. public function getCount()
  13. {
  14. return $this->_count;
  15. }
  16. /**
  17. * @var array
  18. */
  19. private $_data;
  20. public function setData($data)
  21. {
  22. $this->_data = $data;
  23. }
  24. public function getData()
  25. {
  26. return $this->_data;
  27. }
  28. function jsonSerialize()
  29. {
  30. return array(
  31. "Count" => $this->_count,
  32. "Data" => $this->_data
  33. );
  34. }
  35. function __construct($count = 0, $data = array())
  36. {
  37. $this->_count = $count;
  38. $this->_data = $data;
  39. }
  40. function map(callable $callback)
  41. {
  42. $values = [];
  43. foreach ($this->_data as $data) {
  44. $values[] = $callback($data);
  45. }
  46. return new LuMultipleDbo($this->_count, $values);
  47. }
  48. }