Skip to content

Commit

Permalink
Merge pull request #10 from rejoice-framework/master-dev
Browse files Browse the repository at this point in the history
fix: fix simulator console not displaying well on second question
  • Loading branch information
prinx authored May 7, 2021
2 parents 9f0e638 + 4976dde commit bd6ad8f
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/Console/Commands/SimulatorConsoleCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ class SimulatorConsoleCommand extends FrameworkCommand
'error' => 'error',
];

/**
* Codepage used on Windows cmd.exe.
*
* @var int
*/
protected $codepage;

public function configure()
{
$this->setName('simulator:console')
Expand Down Expand Up @@ -117,8 +124,6 @@ public function simulate()
if ($response->isSuccess() && is_array($responseData)) {
$this->drawSeparationLine(['middle' => ' MENU ']);

// $this->showMetadataIfExists($responseData);

if ($this->ussdWantsUserResponse($responseData)) {
$this->getUserResponseAndSend($responseData);
} else {
Expand Down Expand Up @@ -156,14 +161,27 @@ public function end()

public function generateDisplayTable($data)
{
if (\function_exists('sapi_windows_cp_set')) {
@sapi_windows_cp_set($this->getCodepage());
}

$menuScreen = $this->createTable();
$menuScreen->setHeaders(['MENU SCREEN'])
->addRow([$data['message']])
->setColumnMaxWidth(0, 50)
->setStyle('box')
->border('box-double')
->show();
}

public function getCodepage()
{
if (is_null($this->codepage)) {
$this->codepage = sapi_windows_cp_get('');
}

return $this->codepage;
}

public function getUserResponseAndSend($data)
{
$this->generateDisplayTable($data);
Expand Down

0 comments on commit bd6ad8f

Please sign in to comment.