Interface and Abstract class for Generators

This commit is contained in:
Juan Pablo Vial
2024-12-22 11:02:02 -03:00
parent 3dc7259ccb
commit 01e6cef219
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,9 @@
<?php
namespace ProVM\Concept;
use Symfony\Component\Console\Style\StyleInterface;
interface Generator
{
public function generate(StyleInterface $io, bool $dryRun = false): void;
}

View File

@ -0,0 +1,19 @@
<?php
namespace ProVM\Enforce;
use Psr\Log\LoggerInterface;
use Symfony\Component\Console\Style\StyleInterface;
use ProVM\Concept;
abstract class Generator implements Concept\Generator
{
public function __construct(protected LoggerInterface $logger) {}
protected function log(string $message, bool $output = false, ?StyleInterface $io = null): void
{
$this->logger->info($message);
if ($output) {
$io->note($message);
}
}
}