Commit 0724733f authored by Guillaume Perréal's avatar Guillaume Perréal
Browse files

Utilise un tableau pour les substituions dans les templates d'en-ete.

No related merge requests found
Showing with 5 additions and 22 deletions
+5 -22
......@@ -5,36 +5,24 @@
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace Irstea\CS\HeaderComment;
use Irstea\CS\Composer\ComposerPackageInterface;
use Irstea\CS\Git\GitRepositoryInterface;
/**
* Class TemplateFormatter.
*/
final class TemplateFormatter implements TemplateFormatterInterface
{
/**
* @var GitRepositoryInterface
*/
private $gitRepository;
/**
* @var ComposerPackageInterface
*/
private $composerPackage;
/** @var array */
private $variables;
/**
* TemplateFormatter constructor.
*/
public function __construct(GitRepositoryInterface $gitRepository, ComposerPackageInterface $composerPackage)
public function __construct(array $variables)
{
$this->gitRepository = $gitRepository;
$this->composerPackage = $composerPackage;
$this->variables = $variables;
}
/**
......@@ -42,12 +30,7 @@ final class TemplateFormatter implements TemplateFormatterInterface
*/
public function format(string $template): string
{
$variables = [
'%package%' => $this->composerPackage->getName(),
'%description%' => $this->composerPackage->getDescription(),
'%yearRange%' => $this->gitRepository->getYearRange(),
'%copyrightHolder%' => 'INRAE',
];
$variables = [] + $this->variables;
$variables['%copyright%'] = str_replace(
array_keys($variables),
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment