From 96ec8ad6b7b01521043a83f19d24c6bb9a4c1ece Mon Sep 17 00:00:00 2001 From: Ronald Chaplin Date: Mon, 19 Mar 2018 23:57:39 -0400 Subject: [PATCH] Updating methods to align with core naming conventions. --- src/Console/ConsoleOptionParser.php | 31 +++++++++---------- .../Console/ConsoleOptionParserTest.php | 6 ++-- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/Console/ConsoleOptionParser.php b/src/Console/ConsoleOptionParser.php index c767dd27c68..8408b59104d 100644 --- a/src/Console/ConsoleOptionParser.php +++ b/src/Console/ConsoleOptionParser.php @@ -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; } /** diff --git a/tests/TestCase/Console/ConsoleOptionParserTest.php b/tests/TestCase/Console/ConsoleOptionParserTest.php index a2a922a5f25..2c4b6b68876 100644 --- a/tests/TestCase/Console/ConsoleOptionParserTest.php +++ b/tests/TestCase/Console/ConsoleOptionParserTest.php @@ -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();