Skip to content

Commit

Permalink
Updating methods to align with core naming conventions.
Browse files Browse the repository at this point in the history
  • Loading branch information
t73biz committed Mar 20, 2018
1 parent 1fe3e50 commit 96ec8ad
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
31 changes: 14 additions & 17 deletions src/Console/ConsoleOptionParser.php
Expand Up @@ -414,30 +414,27 @@ public function epilog($text = null)
return $this->getEpilog();
}

/**
* Gets the subcommandSort Property
*
* @return bool
*/
public function getSubcommandSort()
/**
* Enables sorting of subcommands
*
* @param bool $value Whether or not to sort subcommands
* @return $this
*/
public function enableSubcommandSort($value = true)
{
return $this->_subcommandSort;
$this->_subcommandSort = (bool)$value;

return $this;
}

/**
* Sets the subcommandSort property.
* Checks whether or not sorting is enabled for subcommands.
*
* @param bool $sort Whether or not the ConsoleOptionParser should sort subcommands
*
* @return $this
* @return bool
*/
public function setSubcommandSort($sort)
public function isSubcommandSortEnabled()
{
if ($sort !== true) {
$this->_subcommandSort = false;
}

return $this;
return $this->_subcommandSort;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Console/ConsoleOptionParserTest.php
Expand Up @@ -657,9 +657,9 @@ public function testAddSubcommandObject()
public function testAddSubcommandSort()
{
$parser = new ConsoleOptionParser('test', false);
$this->assertEquals(true, $parser->getSubcommandSort());
$parser->setSubcommandSort(false);
$this->assertEquals(false, $parser->getSubcommandSort());
$this->assertEquals(true, $parser->isSubcommandSortEnabled());
$parser->enableSubcommandSort(false);
$this->assertEquals(false, $parser->isSubcommandSortEnabled());
$parser->addSubcommand(new ConsoleInputSubcommand('betaTest'), []);
$parser->addSubcommand(new ConsoleInputSubcommand('alphaTest'), []);
$result = $parser->subcommands();
Expand Down

0 comments on commit 96ec8ad

Please sign in to comment.