Skip to content

Instantly share code, notes, and snippets.

@osteel
Created February 6, 2022 12:51
Show Gist options
  • Save osteel/b2ccd0597cee8e137ac46e8db37362a8 to your computer and use it in GitHub Desktop.
Save osteel/b2ccd0597cee8e137ac46e8db37362a8 to your computer and use it in GitHub Desktop.
<?php
namespace Osteel\PhpCliDemo\Services;
use Symfony\Component\Console\Style\SymfonyStyle;
class InputOutput extends SymfonyStyle
{
/**
* Ask a question and return the answer.
*/
public function question(string $question): string
{
return $this->ask(sprintf(' ✍️ %s', $question));
}
/**
* Display a message in case of right answer.
*/
public function right(string $message): void
{
$this->block(sprintf(' 🎉 %s', $message), null, 'fg=white;bg=green', ' ', true);
}
/**
* Display a message in case of wrong answer.
*/
public function wrong(string $message): void
{
$this->block(sprintf(' 😮 %s', $message), null, 'fg=white;bg=red', ' ', true);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment