UppercaseTextRenderer.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. * Additional emphasis processing code based on commonmark-java (https://github.com/atlassian/commonmark-java)
  9. * - (c) Atlassian Pty Ltd
  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\Functional\Delimiter;
  15. use League\CommonMark\Node\Inline\Text;
  16. use League\CommonMark\Node\Node;
  17. use League\CommonMark\Renderer\ChildNodeRendererInterface;
  18. use League\CommonMark\Renderer\NodeRendererInterface;
  19. final class UppercaseTextRenderer implements NodeRendererInterface
  20. {
  21. /**
  22. * {@inheritDoc}
  23. */
  24. public function render(Node $node, ChildNodeRendererInterface $childRenderer)
  25. {
  26. UppercaseText::assertInstanceOf($node);
  27. foreach ($node->children() as $child) {
  28. if ($child instanceof Text) {
  29. $child->setLiteral(\mb_strtoupper($child->getLiteral()));
  30. }
  31. }
  32. return $childRenderer->renderNodes($node->children());
  33. }
  34. }