<?php

/*
 * This file is part of Media-Alchemyst.
 *
 * (c) Tiki Wiki CMS Groupware
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace MediaAlchemyst;

use Pimple\Container;

class LegacyPimpleContainer extends Container
{
    /**
     * Reintroduce the 'share' method for backward compatibility with older Pimple versions.
     *
     * @param callable $callable
     * @return \Closure
     */
    public function share(callable $callable)
    {
        return function ($c) use (&$callable) {
            static $object;
            if (null === $object) {
                $object = $callable($c);
            }
            return $object;
        };
    }
}
