Output.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /*
  3. * This file is part of the php-phantomjs.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. namespace JonnyW\PhantomJs\Procedure;
  9. /**
  10. * PHP PhantomJs
  11. *
  12. * @author Jon Wenmoth <contact@jonnyw.me>
  13. */
  14. class Output implements OutputInterface
  15. {
  16. /**
  17. * Output data.
  18. *
  19. * @var array
  20. * @access protected
  21. */
  22. protected $data;
  23. /**
  24. * Output logs.
  25. *
  26. * @var array
  27. * @access protected
  28. */
  29. protected $logs;
  30. /**
  31. * Internal constructor.
  32. *
  33. * @access public
  34. * @return void
  35. */
  36. public function __construct()
  37. {
  38. $this->data = array();
  39. $this->logs = array();
  40. }
  41. /**
  42. * Import data.
  43. *
  44. * @param array $data
  45. * @access public
  46. */
  47. public function import(array $data)
  48. {
  49. $this->data = $data;
  50. }
  51. /**
  52. * Set data value.
  53. *
  54. * @access public
  55. * @param string $name
  56. * @param mixed $value
  57. * @return \JonnyW\PhantomJs\Procedure\Output
  58. */
  59. public function set($name, $value)
  60. {
  61. $this->data[$name] = $value;
  62. return $this;
  63. }
  64. /**
  65. * Get data value.
  66. *
  67. * @access public
  68. * @param string $name
  69. * @return mixed
  70. */
  71. public function get($name)
  72. {
  73. if (isset($this->data[$name])) {
  74. return $this->data[$name];
  75. }
  76. return '';
  77. }
  78. /**
  79. * Log data.
  80. *
  81. * @access public
  82. * @param string $data
  83. */
  84. public function log($data)
  85. {
  86. $this->logs[] = $data;
  87. }
  88. /**
  89. * Get log data.
  90. *
  91. * @access public
  92. * @return array
  93. */
  94. public function getLogs()
  95. {
  96. return $this->logs;
  97. }
  98. }