MockNode.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace PHPHtmlParser\Dom;
  3. /**
  4. * This mock object is used solely for testing the abstract
  5. * class Node with out any potential side effects caused
  6. * by testing a supper class of Node.
  7. *
  8. * This object is not to be used for any other reason.
  9. */
  10. class MockNode extends InnerNode
  11. {
  12. /**
  13. * Mock of innner html.
  14. */
  15. public function innerHtml(): string
  16. {
  17. return '';
  18. }
  19. /**
  20. * Mock of outer html.
  21. */
  22. public function outerHtml(): string
  23. {
  24. return '';
  25. }
  26. /**
  27. * Mock of text.
  28. */
  29. public function text(): string
  30. {
  31. return '';
  32. }
  33. /**
  34. * Clear content of this node
  35. */
  36. protected function clear(): void
  37. {
  38. $this->innerHtml = null;
  39. $this->outerHtml = null;
  40. $this->text = null;
  41. if (is_null($this->parent) === false) {
  42. $this->parent->clear();
  43. }
  44. }
  45. /**
  46. * Returns all children of this html node.
  47. *
  48. * @return array
  49. */
  50. protected function getIteratorArray(): array
  51. {
  52. return $this->getChildren();
  53. }
  54. }