xprt64/cqrs-es

View on GitHub
src/Dudulina/CodeGeneration/TemplateLoader.php

Summary

Maintainability
A
35 mins
Test Coverage
<?php
/**
 * Copyright (c) 2018 Constantin Galbenu <xprt64@gmail.com>
 */

namespace Dudulina\CodeGeneration;

class TemplateLoader
{
    public function loadTemplate(string $content, string $templateClassName, string $templateNamespace, string $outputShortClassName, string $outputNamespace)
    {
        return str_replace(
            [$templateClassName, '--- This is just a template ---', "namespace $templateNamespace;"],
            [$outputShortClassName, '--- generated by ' . __FILE__ . ' at ' . date('c') . ' ---', $outputNamespace ? "namespace $outputNamespace;" : ''],
            $content);
    }
}