FakeChildNodeRenderer.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of the league/commonmark package.
  5. *
  6. * (c) Colin O'Dell <colinodell@gmail.com>
  7. *
  8. * Original code based on the CommonMark JS reference parser (https://bitly.com/commonmark-js)
  9. * - (c) John MacFarlane
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace League\CommonMark\Tests\Unit\Renderer;
  15. use League\CommonMark\Renderer\ChildNodeRendererInterface;
  16. final class FakeChildNodeRenderer implements ChildNodeRendererInterface
  17. {
  18. private bool $alwaysOutputChildren = false;
  19. public function pretendChildrenExist(): void
  20. {
  21. $this->alwaysOutputChildren = true;
  22. }
  23. /**
  24. * {@inheritDoc}
  25. */
  26. public function renderNodes(iterable $nodes): string
  27. {
  28. if ($this->alwaysOutputChildren) {
  29. return '::children::';
  30. }
  31. // Only return '::children::' if the iterable isn't empty
  32. foreach ($nodes as $node) {
  33. return '::children::';
  34. }
  35. return '';
  36. }
  37. public function getBlockSeparator(): string
  38. {
  39. return '';
  40. }
  41. public function getInnerSeparator(): string
  42. {
  43. return '';
  44. }
  45. }