FakeAdapter.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace League\CommonMark\Tests\Unit\Extension\Embed;
  12. use League\CommonMark\Extension\Embed\Embed;
  13. use League\CommonMark\Extension\Embed\EmbedAdapterInterface;
  14. final class FakeAdapter implements EmbedAdapterInterface
  15. {
  16. /** @var Embed[] */
  17. private array $updatedEmbeds = [];
  18. /**
  19. * {@inheritDoc}
  20. */
  21. public function updateEmbeds(array $embeds): void
  22. {
  23. foreach ($embeds as $embed) {
  24. \assert($embed instanceof Embed);
  25. $embed->setEmbedCode(\sprintf('<iframe class="embed" src="%s"></iframe>', $embed->getUrl()));
  26. $this->updatedEmbeds[] = $embed;
  27. }
  28. }
  29. /**
  30. * @return Embed[]
  31. */
  32. public function getUpdatedEmbeds(): array
  33. {
  34. return $this->updatedEmbeds;
  35. }
  36. }