1<?php
2
3declare(strict_types=1);
4
5namespace JMS\Serializer\Twig;
6
7use JMS\Serializer\SerializationContext;
8use JMS\Serializer\SerializerInterface;
9
10/**
11 * @author Asmir Mustafic <goetas@gmail.com>
12 */
13final class SerializerRuntimeHelper
14{
15    /**
16     * @var SerializerInterface
17     */
18    protected $serializer;
19
20    public function __construct(SerializerInterface $serializer)
21    {
22        $this->serializer = $serializer;
23    }
24
25    /**
26     * @param mixed $object
27     */
28    public function serialize($object, string $type = 'json', ?SerializationContext $context = null): string
29    {
30        return $this->serializer->serialize($object, $type, $context);
31    }
32}
33