<?php
namespace App\V4\Dev\Exporter;
use App\Export\Builder\ExportBuilder;
use App\Export\Builder\ExportBuilderInterface;
use App\Export\Builder\ExporterInterface;
use RuntimeException;
use Symfony\Component\Stopwatch\Stopwatch;
class TraceableExportBuilder implements ExportBuilderInterface
{
/**
* @var ExportBuilder
*/
private $decorated;
/**
* @var Stopwatch
*/
private $stopwatch;
/**
* @param ExportBuilder $decorated
* @param Stopwatch $stopwatch
*/
public function __construct(ExportBuilder $decorated, Stopwatch $stopwatch)
{
$this->decorated = $decorated;
$this->stopwatch = $stopwatch;
}
/**
* @param mixed $entity
* @param string $field
* @param string $exportType
*
* @return ExporterInterface
*
* @throws RuntimeException
*/
public function getExporter($entity, string $field, string $exportType): ExporterInterface
{
$exporter = $this->decorated->getExporter($entity, $field, $exportType);
return new TraceableExporter($exporter, $this->stopwatch);
}
}