1<?php
2
3declare(strict_types=1);
4
5namespace JMS\Serializer\ContextFactory;
6
7use JMS\Serializer\Context;
8
9/**
10 * Context Factory using a callable.
11 */
12abstract class CallableContextFactory
13{
14    /**
15     * @var callable
16     */
17    private $callable;
18
19    public function __construct(callable $callable)
20    {
21        $this->callable = $callable;
22    }
23
24    /**
25     * @return mixed
26     */
27    protected function createContext(): Context
28    {
29        $callable = $this->callable;
30
31        return $callable();
32    }
33}
34