1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.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
12namespace Symfony\Component\HttpFoundation\Session\Storage\Handler;
13
14use Symfony\Component\Cache\Marshaller\MarshallerInterface;
15
16/**
17 * @author Ahmed TAILOULOUTE <ahmed.tailouloute@gmail.com>
18 */
19class IdentityMarshaller implements MarshallerInterface
20{
21    /**
22     * {@inheritdoc}
23     */
24    public function marshall(array $values, ?array &$failed): array
25    {
26        foreach ($values as $key => $value) {
27            if (!\is_string($value)) {
28                throw new \LogicException(sprintf('%s accepts only string as data.', __METHOD__));
29            }
30        }
31
32        return $values;
33    }
34
35    /**
36     * {@inheritdoc}
37     */
38    public function unmarshall(string $value): string
39    {
40        return $value;
41    }
42}
43