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 @@ ...@@ -5,36 +5,24 @@
* *
* For the full copyright and license information, please view the LICENSE * For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code. * file that was distributed with this source code.
*
*/ */
namespace Irstea\CS\HeaderComment; namespace Irstea\CS\HeaderComment;
use Irstea\CS\Composer\ComposerPackageInterface;
use Irstea\CS\Git\GitRepositoryInterface;
/** /**
* Class TemplateFormatter. * Class TemplateFormatter.
*/ */
final class TemplateFormatter implements TemplateFormatterInterface final class TemplateFormatter implements TemplateFormatterInterface
{ {
/** /** @var array */
* @var GitRepositoryInterface private $variables;
*/
private $gitRepository;
/**
* @var ComposerPackageInterface
*/
private $composerPackage;
/** /**
* TemplateFormatter constructor. * TemplateFormatter constructor.
*/ */
public function __construct(GitRepositoryInterface $gitRepository, ComposerPackageInterface $composerPackage) public function __construct(array $variables)
{ {
$this->gitRepository = $gitRepository; $this->variables = $variables;
$this->composerPackage = $composerPackage;
} }
/** /**
...@@ -42,12 +30,7 @@ final class TemplateFormatter implements TemplateFormatterInterface ...@@ -42,12 +30,7 @@ final class TemplateFormatter implements TemplateFormatterInterface
*/ */
public function format(string $template): string public function format(string $template): string
{ {
$variables = [ $variables = [] + $this->variables;
'%package%' => $this->composerPackage->getName(),
'%description%' => $this->composerPackage->getDescription(),
'%yearRange%' => $this->gitRepository->getYearRange(),
'%copyrightHolder%' => 'INRAE',
];
$variables['%copyright%'] = str_replace( $variables['%copyright%'] = str_replace(
array_keys($variables), 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