for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the ICanBoogie package.
*
* (c) Olivier Laviale <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ICanBoogie\Transformation\PSR;
use ICanBoogie\Transformation\TransformationProviderAbstract;
use Psr\Container\ContainerInterface;
/**
* Provides transformations from a container.
class TransformationProvider extends TransformationProviderAbstract
{
* @var ContainerInterface
private $container;
* @var array
private $cache = [];
* @inheritdoc
* @param ContainerInterface $container
public function __construct(array $transformations, ContainerInterface $container)
$this->container = $container;
parent::__construct($transformations);
}
protected function resolve($transformation): callable
$resolved = &$this->cache[$transformation];
return $resolved ?: $resolved = $this->container->get($transformation);