diff --git a/resources/commands.php b/resources/commands.php index a530995d9a109cc2a439f9ca3fad57aa8d035bbd..6b688477c8eb91cda4bc523fe4d923bcc3d7b106 100644 --- a/resources/commands.php +++ b/resources/commands.php @@ -7,13 +7,13 @@ echo PHP_EOL . 'Commands:' . PHP_EOL; $data = []; $nameWidth = 0; foreach ($commands as $command) { - if (strlen($command->name()) > $nameWidth) { - $nameWidth = strlen($command->name()); + if (strlen($command->getName()) > $nameWidth) { + $nameWidth = strlen($command->getName()); } $data[] = [ - $command->name(), - $command->description(true) + $command->getName(), + $command->getDescription(true) ]; } diff --git a/resources/usage.php b/resources/usage.php index 7c714474e4407b0dc95aec3cda67fbfff17e414c..39c9536ae1c819d24554acf7a7ce4040a61c03eb 100644 --- a/resources/usage.php +++ b/resources/usage.php @@ -9,7 +9,7 @@ use GetOpt\GetOpt; echo 'Usage: ' . $getopt->get(GetOpt::SETTING_SCRIPT_NAME) . ' '; if (isset($command)) { - echo $command->name() . ' '; + echo $command->getName() . ' '; } elseif ($getopt->hasCommands()) { echo '<command> '; } @@ -40,5 +40,5 @@ if (!$lastOperandMultiple && !$getopt->get(GetOpt::SETTING_STRICT_OPERANDS)) { echo PHP_EOL; if (isset($command)) { - echo PHP_EOL . $command->description() . PHP_EOL . PHP_EOL; + echo PHP_EOL . $command->getDescription() . PHP_EOL . PHP_EOL; } diff --git a/src/Command.php b/src/Command.php index f572287a6934ac54cc7082e47a71997990b6da65..360fdd0327835beae469fee843b910e9f962df63 100644 --- a/src/Command.php +++ b/src/Command.php @@ -111,7 +111,7 @@ class Command /** * @return string */ - public function name() + public function getName() { return $this->name; } @@ -119,7 +119,7 @@ class Command /** * @return mixed */ - public function handler() + public function getHandler() { return $this->handler; } @@ -129,12 +129,15 @@ class Command * * @return string */ - public function description() + public function getDescription() { return $this->longDescription; } - public function shortDescription() + /** + * @return string + */ + public function getShortDescription() { return $this->shortDescription; } diff --git a/src/GetOpt.php b/src/GetOpt.php index 7168c05c44313925e91e881bb6d9c1bcf08b6b61..79028b146eef943497cdd2377e0e3be407d095df 100644 --- a/src/GetOpt.php +++ b/src/GetOpt.php @@ -267,7 +267,7 @@ class GetOpt implements \Countable, \ArrayAccess, \IteratorAggregate throw new \InvalidArgumentException('$command has conflicting options'); } } - $this->commands[$command->name()] = $command; + $this->commands[$command->getName()] = $command; return $this; } diff --git a/test/CommandTest.php b/test/CommandTest.php index 195d6833b84d4e288bd7146219fc5a6e7365f2f1..7ec79b4e0daeed417d938ea938a84957b64559c4 100644 --- a/test/CommandTest.php +++ b/test/CommandTest.php @@ -31,7 +31,7 @@ class CommandTest extends TestCase /** @test */ public function constructorSavesName() { - self::assertSame('the-name', $this->command->name()); + self::assertSame('the-name', $this->command->getName()); } /** @dataProvider dataNamesNotAllowed @@ -55,7 +55,7 @@ class CommandTest extends TestCase /** @test */ public function constructorSavesHandler() { - self::assertSame([ '\PDO', 'getAvailableDrivers' ], $this->command->handler()); + self::assertSame([ '\PDO', 'getAvailableDrivers' ], $this->command->getHandler()); } /** @test */ @@ -80,7 +80,7 @@ class CommandTest extends TestCase $command->setShortDescription('short description'); - self::assertSame('short description', $command->description()); + self::assertSame('short description', $command->getDescription()); } /** @test */ @@ -90,7 +90,7 @@ class CommandTest extends TestCase $command->setDescription('long description'); - self::assertSame('long description', $command->shortDescription()); + self::assertSame('long description', $command->getShortDescription()); } /** @test */