diff --git a/src/EntityBuilder/AbstractEntityCommand.php b/src/EntityBuilder/AbstractEntityCommand.php index c4fb635..ee7c2c2 100644 --- a/src/EntityBuilder/AbstractEntityCommand.php +++ b/src/EntityBuilder/AbstractEntityCommand.php @@ -16,7 +16,7 @@ use Symfony\Component\Console\Style\SymfonyStyle; abstract class AbstractEntityCommand extends Command { public function __construct( - private EntityManagerInterface $em, + protected readonly EntityManagerInterface $em, ) { parent::__construct(); @@ -51,8 +51,8 @@ abstract class AbstractEntityCommand extends Command $builder->setAll($entity); $this->em->persist($entity); - if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to create %s with above properties', $entity)))) { - $io->success(sprintf('Object "%s" (id: %s) stored successfully', $entity, $entity->getId())); + if ($io->askQuestion(new ConfirmationQuestion(sprintf('Are you sure you want to create "%s" with above properties', $entity)))) { + $io->success(sprintf('Object "%s" stored successfully', $entity)); } } while ($io->askQuestion(new ConfirmationQuestion('Create another?', false))); } elseif ($input->getOption('modify')) { diff --git a/src/EntityBuilder/BaseElement.php b/src/EntityBuilder/BaseElement.php index 4a10b0b..1632e92 100644 --- a/src/EntityBuilder/BaseElement.php +++ b/src/EntityBuilder/BaseElement.php @@ -8,13 +8,16 @@ class BaseElement { public function getQuestion(): Question { - $name = ucfirst(strtolower(implode(' ', preg_split('/(?=[A-Z])/', $this->getProperty())))); - return new Question($name); + return new Question($this->getPrettyProperty()); + } + + protected function getPrettyProperty(): string + { + return ucfirst(strtolower(implode(' ', preg_split('/(?=[A-Z])/', $this->getProperty())))); } public function __construct( private readonly string $property, - private readonly array $config = [], ) { } diff --git a/src/EntityBuilder/ChoiceElement.php b/src/EntityBuilder/ChoiceElement.php new file mode 100644 index 0000000..c106213 --- /dev/null +++ b/src/EntityBuilder/ChoiceElement.php @@ -0,0 +1,23 @@ +getPrettyProperty(), $this->choices); + } + + public function __construct( + string $property, + private readonly array $choices, + ) + { + parent::__construct($property); + } + +} \ No newline at end of file