IdentityMarshaller.php 972 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
  11. use Symfony\Component\Cache\Marshaller\MarshallerInterface;
  12. /**
  13. * @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com>
  14. */
  15. class IdentityMarshaller implements MarshallerInterface
  16. {
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function marshall(array $values, ?array &$failed): array
  21. {
  22. foreach ($values as $key => $value) {
  23. if (!\is_string($value)) {
  24. throw new \LogicException(sprintf('%s accepts only string as data.', __METHOD__));
  25. }
  26. }
  27. return $values;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function unmarshall(string $value): string
  33. {
  34. return $value;
  35. }
  36. }