From 34427e7cd483a172a9ec3baff19ebb648d5060ab Mon Sep 17 00:00:00 2001 From: Christopher Moore Date: Sat, 2 Jul 2016 07:10:27 -0700 Subject: [PATCH] use camel case for mutation name --- .../Console/Commands/MutationMakeCommand.php | 16 ++++++++++++++++ src/Support/Console/Commands/stubs/mutation.stub | 2 +- .../Console/Commands/stubs/relay_mutation.stub | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Support/Console/Commands/MutationMakeCommand.php b/src/Support/Console/Commands/MutationMakeCommand.php index 4768f3addb..555169b121 100644 --- a/src/Support/Console/Commands/MutationMakeCommand.php +++ b/src/Support/Console/Commands/MutationMakeCommand.php @@ -64,4 +64,20 @@ protected function getOptions() ['relay', null, InputOption::VALUE_NONE, 'Generate a Relay Mutation.'], ]; } + + /** + * Replace the class name for the given stub. + * + * @param string $stub + * @param string $name + * @return string + */ + protected function replaceClass($stub, $name) + { + $class = str_replace($this->getNamespace($name).'\\', '', $name); + + $stub = str_replace('DummyCamelClass', camel_case($class), $stub); + + return str_replace('DummyClass', $class, $stub); + } } diff --git a/src/Support/Console/Commands/stubs/mutation.stub b/src/Support/Console/Commands/stubs/mutation.stub index 6df854f829..e73f85b8d3 100644 --- a/src/Support/Console/Commands/stubs/mutation.stub +++ b/src/Support/Console/Commands/stubs/mutation.stub @@ -13,7 +13,7 @@ class DummyClass extends GraphQLMutation * @var array */ protected $attributes = [ - 'name' => 'DummyClass' + 'name' => 'DummyCamelClass' ]; /** diff --git a/src/Support/Console/Commands/stubs/relay_mutation.stub b/src/Support/Console/Commands/stubs/relay_mutation.stub index 6d80d1736d..b63dffbfc4 100644 --- a/src/Support/Console/Commands/stubs/relay_mutation.stub +++ b/src/Support/Console/Commands/stubs/relay_mutation.stub @@ -16,7 +16,7 @@ class DummyClass extends GraphQLMutation implements RelayMutation * @var array */ protected $attributes = [ - 'name' => 'DummyClass' + 'name' => 'DummyCamelClass' ]; /**