Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersai committed Mar 31, 2022
2 parents f4027da + 1404a13 commit 0f20134
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Commands/ActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function handle()

$this->info($this->className($name).' action created successfully');
} else {
$this->error('File Already exists !');
$this->error('File already exists !');
}
}
}
2 changes: 1 addition & 1 deletion src/Commands/StateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function handle()

$this->info($this->className($name).' state created successfully');
} else {
$this->error('File Already exists !');
$this->error('File already exists !');
}
}
}
8 changes: 4 additions & 4 deletions src/Machine.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public function run()

$this->ensureClassExist(
$active,
'Active State Class needs to be set before ussd machine can'
. ' run. It may be that your session has ended.'
'Active State Class needs to be set before ussd machine can '
. 'run. It may be that your session has ended.'
);

$activeClass = new $active();
Expand All @@ -90,8 +90,8 @@ public function run()
$this->processAction(
$stateClass,
$state,
'Initial State Class needs to be set before'
. ' ussd machine can run.'
'Initial State Class needs to be set before '
. 'ussd machine can run.'
);

$this->record->set('__active', $state);
Expand Down
8 changes: 4 additions & 4 deletions src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class Menu
public const NUMBERING_NUMERIC = 'numeric';

public const ITEMS_SEPARATOR_NO_LINE_BREAK = "";
public const ITEMS_SEPARATOR_LINE_BREAK = "\n";
public const ITEMS_SEPARATOR_DOUBLE_LINE_BREAK = "\n\n";
public const ITEMS_SEPARATOR_LINE_BREAK = PHP_EOL;
public const ITEMS_SEPARATOR_DOUBLE_LINE_BREAK = PHP_EOL.PHP_EOL;

public const NUMBERING_SEPARATOR_NO_SPACE = "";
public const NUMBERING_SEPARATOR_SPACE = " ";
Expand Down Expand Up @@ -88,14 +88,14 @@ private function listParser(

public function lineBreak(int $number = 1): self
{
$this->menu .= str_repeat("\n", $number);
$this->menu .= str_repeat(PHP_EOL, $number);

return $this;
}

public function line(string $text): self
{
$this->menu .= "$text\n";
$this->menu .= "$text".PHP_EOL;

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function ($key) {
*/
protected function getValues($values)
{
$newValues = array();
$newValues = [];
foreach ($values as $key => $value) {
$newValues[$this->getKey($key)] = $value;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public function get($key, $default = null)
public function getMultiple($keys, $default = null)
{
return array_values(
(array)$this->cache->getMultiple($this->getKeys($keys), $this->getDefault($default))
(array) $this->cache->getMultiple($this->getKeys($keys), $this->getDefault($default))
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

abstract class State
{
/** @var int */
/** @var string */
public const INPUT = 'input';

/** @var int */
/** @var string */
public const PROMPT = 'prompt';

/** @var string */
Expand Down Expand Up @@ -36,6 +36,7 @@ public function render(): string
{
$this->menu = new Menu();
$this->beforeRendering();

return $this->menu->toString();
}

Expand All @@ -53,6 +54,7 @@ public function next(?string $input): ?string
{
$this->decision = new Decision($input);
$this->afterRendering($input);

return $this->decision->outcome();
}

Expand Down
2 changes: 0 additions & 2 deletions src/Ussd.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Sparors\Ussd;

use Illuminate\Support\Facades\Cache;

class Ussd
{
/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Commands/ActionCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test_it_print_out_error_when_class_exists()
{
File::shouldReceive('exists')->once()->andReturn(true);
$this->artisan('ussd:action', ['name' => 'save'])
->expectsOutput('File Already exists !')
->expectsOutput('File already exists !')
->assertExitCode(0);
}
}
2 changes: 1 addition & 1 deletion tests/Commands/StateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function test_it_print_out_error_when_class_exists()
{
File::shouldReceive('exists')->once()->andReturn(true);
$this->artisan('ussd:state', ['name' => 'welcome'])
->expectsOutput('File Already exists !')
->expectsOutput('File already exists !')
->assertExitCode(0);
}
}
1 change: 1 addition & 0 deletions tests/StateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class StateTest extends TestCase
public function test_state_works_correctly()
{
$hello = new HelloState();

$this->assertEquals('Hello World', $hello->render());

$this->assertEquals(RunAction::class, $hello->next('1'));
Expand Down

0 comments on commit 0f20134

Please sign in to comment.