Skip to content

Commit

Permalink
[console] Apply PSR-2 code style. (#3677)
Browse files Browse the repository at this point in the history
* [console] Apply PSR-2 code style.

* [console] Apply PSR-2 code style.
  • Loading branch information
jmolivas authored Jan 10, 2018
1 parent 39c432d commit 44facf3
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion src/Command/Generate/AjaxCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
$this->trans('commands.generate.controller.questions.class'),
'AjaxCommand',
function ($class) {
return $this->validator->validateClassName($class);
return $this->validator->validateClassName($class);
}
);
$input->setOption('class', $class);
Expand Down
66 changes: 33 additions & 33 deletions src/Command/Generate/PluginRestResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ protected function execute(InputInterface $input, OutputInterface $output)

$prepared_plugin = [];
foreach ($plugin_states as $plugin_state) {
$prepared_plugin[$plugin_state] = $http_methods[$plugin_state];
$prepared_plugin[$plugin_state] = $http_methods[$plugin_state];
}

$this->generator->generate($module, $class_name, $plugin_label, $plugin_id, $plugin_url, $prepared_plugin);
Expand Down Expand Up @@ -224,7 +224,6 @@ function ($class) {

$input->setOption('plugin-states', $plugin_states);
}

}

/**
Expand All @@ -233,36 +232,37 @@ function ($class) {
* @return array
* Available HTTP methods.
*/
protected function getHttpMethods() {
return [
'GET' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
'PUT' => [
'http_code' => 201,
'response_class' => 'ModifiedResourceResponse',
],
'POST' => [
'http_code' => 200,
'response_class' => 'ModifiedResourceResponse',
],
'PATCH' => [
'http_code' => 204,
'response_class' => 'ModifiedResourceResponse',
],
'DELETE' => [
'http_code' => 204,
'response_class' => 'ModifiedResourceResponse',
],
'HEAD' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
'OPTIONS' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
];
protected function getHttpMethods()
{
return [
'GET' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
'PUT' => [
'http_code' => 201,
'response_class' => 'ModifiedResourceResponse',
],
'POST' => [
'http_code' => 200,
'response_class' => 'ModifiedResourceResponse',
],
'PATCH' => [
'http_code' => 204,
'response_class' => 'ModifiedResourceResponse',
],
'DELETE' => [
'http_code' => 204,
'response_class' => 'ModifiedResourceResponse',
],
'HEAD' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
'OPTIONS' => [
'http_code' => 200,
'response_class' => 'ResourceResponse',
],
];
}
}
4 changes: 2 additions & 2 deletions src/Command/Shared/ModuleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public function moduleRequirement(array $module, DrupalStyle $io)
/**
* Get module name from user.
*
* @param \Drupal\Console\Core\Style\DrupalStyle $io
* @param \Drupal\Console\Core\Style\DrupalStyle $io
* Console interface.
* @param InputInterface $input
* @param InputInterface $input
* Input interface.
*
* @return mixed|string
Expand Down
2 changes: 1 addition & 1 deletion src/Command/User/LoginUrlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ protected function interact(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);

$this->userQuestion();
$this->userQuestion();
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/Utils/Validator.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,25 +325,25 @@ public function validateExtensions($extensions_list, $type, DrupalStyle $io)
return $extensions;
}

/**
/**
* Validate if http methods exist.
*
* @param array $httpMethods Array http methods.
* @param array $httpMethods Array http methods.
* @param array $availableHttpMethods Array of available http methods.
*
* @return string
*/
public function validateHttpMethods($httpMethods, $availableHttpMethods)
{
if (empty($httpMethods)) {
return null;
}
public function validateHttpMethods($httpMethods, $availableHttpMethods)
{
if (empty($httpMethods)) {
return null;
}

$missing_methods = array_diff(array_values($httpMethods), array_keys($availableHttpMethods));
if (!empty($missing_methods)) {
throw new \InvalidArgumentException(sprintf('HTTP methods "%s" are invalid.', implode(', ', $missing_methods)));
}
$missing_methods = array_diff(array_values($httpMethods), array_keys($availableHttpMethods));
if (!empty($missing_methods)) {
throw new \InvalidArgumentException(sprintf('HTTP methods "%s" are invalid.', implode(', ', $missing_methods)));
}

return $httpMethods;
}
return $httpMethods;
}
}

0 comments on commit 44facf3

Please sign in to comment.