Skip to content

Commit

Permalink
Merge pull request #3 from wkjagt/command-translator
Browse files Browse the repository at this point in the history
Fix case where command namespace contains Command
  • Loading branch information
laracasts committed Jul 3, 2014
2 parents 1f65b8c + e82b9b4 commit 89b47ce
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Laracasts/Commander/BasicCommandTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class BasicCommandTranslator implements CommandTranslator {
*/
public function toCommandHandler($command)
{
$handler = str_replace('Command', 'CommandHandler', get_class($command));
$commandClass = get_class($command);
$handler = substr_replace($commandClass, 'CommandHandler', strrpos($commandClass, 'Command'));

if ( ! class_exists($handler))
{
Expand All @@ -31,7 +32,8 @@ public function toCommandHandler($command)
*/
public function toValidator($command)
{
return str_replace('Command', 'Validator', get_class($command));
$commandClass = get_class($command);
return substr_replace($commandClass, 'Validator', strrpos($commandClass, 'Command'));
}

}

0 comments on commit 89b47ce

Please sign in to comment.