InMemoryWriter.php 867B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Exporter\Writer;
  11. use Exporter\Exception\InvalidDataFormatException;
  12. class InMemoryWriter implements WriterInterface
  13. {
  14. protected $elements;
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function open()
  19. {
  20. $this->elements = array();
  21. }
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function close()
  26. {
  27. return $this->elements;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function write(array $data)
  33. {
  34. $this->elements[] = $data;
  35. }
  36. /**
  37. * @return array
  38. */
  39. public function getElements()
  40. {
  41. return $this->elements;
  42. }
  43. }