@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @package Platine\Framework\Console\Command |
57 | 57 | * @template T |
58 | 58 | */ |
59 | -class ConfigCommand extends Command |
|
60 | -{ |
|
59 | +class ConfigCommand extends Command { |
|
61 | 60 | /** |
62 | 61 | * The configuration instance |
63 | 62 | * @var Config<T> |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | * Create new instance |
69 | 68 | * @param Config<T> $config |
70 | 69 | */ |
71 | - public function __construct(Config $config) |
|
72 | - { |
|
70 | + public function __construct(Config $config) { |
|
73 | 71 | parent::__construct('config', 'Command to manage configuration'); |
74 | 72 | |
75 | 73 | $this->addOption('-l|--list', 'List the configuration', '', false); |
@@ -81,9 +79,8 @@ discard block |
||
81 | 79 | /** |
82 | 80 | * {@inheritdoc} |
83 | 81 | */ |
84 | - public function execute() |
|
85 | - { |
|
86 | - if ($this->getOptionValue('list')) { |
|
82 | + public function execute() { |
|
83 | + if ($this->getOptionValue('list')) { |
|
87 | 84 | $this->showConfigList(); |
88 | 85 | } |
89 | 86 | } |
@@ -102,13 +99,13 @@ discard block |
||
102 | 99 | $items = (array) $this->config->get($type, []); |
103 | 100 | /** @var array<int, array<int, array<string, string>>> $rows*/ |
104 | 101 | $rows = []; |
105 | - foreach ($items as $name => $value) { |
|
102 | + foreach ($items as $name => $value) { |
|
106 | 103 | $valueStr = Str::stringify($value); |
107 | - if (is_int($name)) { |
|
104 | + if (is_int($name)) { |
|
108 | 105 | $rows[] = [ |
109 | 106 | 'value' => $valueStr |
110 | 107 | ]; |
111 | - } else { |
|
108 | + } else { |
|
112 | 109 | $rows[] = [ |
113 | 110 | 'name' => $name, |
114 | 111 | 'value' => $valueStr |
@@ -84,7 +84,7 @@ |
||
84 | 84 | ) { |
85 | 85 | parent::__construct($application, $filesystem); |
86 | 86 | $this->setName('make:validator') |
87 | - ->setDescription('Command to generate new validator class'); |
|
87 | + ->setDescription('Command to generate new validator class'); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -171,8 +171,8 @@ |
||
171 | 171 | { |
172 | 172 | $content = parent::createClass(); |
173 | 173 | |
174 | - $formParameter = $this->replaceFormParameterName($content); |
|
175 | - $validationDataBody = $this->getValidationDataBody($formParameter); |
|
174 | + $formParameter = $this->replaceFormParameterName($content); |
|
175 | + $validationDataBody = $this->getValidationDataBody($formParameter); |
|
176 | 176 | |
177 | 177 | return $this->getValidationRulesBody($validationDataBody); |
178 | 178 | } |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | * @class MakeValidatorCommand |
61 | 61 | * @package Platine\Framework\Console\Command |
62 | 62 | */ |
63 | -class MakeValidatorCommand extends MakeCommand |
|
64 | -{ |
|
63 | +class MakeValidatorCommand extends MakeCommand { |
|
65 | 64 | /** |
66 | 65 | * {@inheritdoc} |
67 | 66 | */ |
@@ -81,7 +80,7 @@ discard block |
||
81 | 80 | public function __construct( |
82 | 81 | Application $application, |
83 | 82 | Filesystem $filesystem |
84 | - ) { |
|
83 | + ) { |
|
85 | 84 | parent::__construct($application, $filesystem); |
86 | 85 | $this->setName('make:validator') |
87 | 86 | ->setDescription('Command to generate new validator class'); |
@@ -98,7 +97,7 @@ discard block |
||
98 | 97 | $io = $this->io(); |
99 | 98 | |
100 | 99 | $paramClass = $io->prompt('Enter the form parameter full class name', null); |
101 | - while (!class_exists($paramClass)) { |
|
100 | + while (!class_exists($paramClass)) { |
|
102 | 101 | $paramClass = $io->prompt('Class does not exists, please enter the form parameter full class name', null); |
103 | 102 | } |
104 | 103 | |
@@ -187,12 +186,12 @@ discard block |
||
187 | 186 | $reflection = new ReflectionClass($this->paramClass); |
188 | 187 | $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC); |
189 | 188 | |
190 | - if (!empty($methods)) { |
|
191 | - foreach ($methods as /** @var ReflectionMethod $method */ $method) { |
|
189 | + if (!empty($methods)) { |
|
190 | + foreach ($methods as /** @var ReflectionMethod $method */ $method) { |
|
192 | 191 | $returnType = $method->getReturnType(); |
193 | - if ($returnType !== null) { |
|
192 | + if ($returnType !== null) { |
|
194 | 193 | $name = $method->name; |
195 | - if (substr($name, 0, 3) === 'get' && $name !== 'getDefault') { |
|
194 | + if (substr($name, 0, 3) === 'get' && $name !== 'getDefault') { |
|
196 | 195 | $field = str_replace('get', '', $name); |
197 | 196 | $list[Str::snake($field)] = $name; |
198 | 197 | } |
@@ -211,7 +210,7 @@ discard block |
||
211 | 210 | protected function getValidationRulesBody(string $content): string |
212 | 211 | { |
213 | 212 | $result = ''; |
214 | - foreach ($this->getParameterProperties() as $field => $getter) { |
|
213 | + foreach ($this->getParameterProperties() as $field => $getter) { |
|
215 | 214 | $result .= <<<EOF |
216 | 215 | \$this->addRules('$field', [ |
217 | 216 | |
@@ -231,7 +230,7 @@ discard block |
||
231 | 230 | protected function getValidationDataBody(string $content): string |
232 | 231 | { |
233 | 232 | $result = ''; |
234 | - foreach ($this->getParameterProperties() as $field => $getter) { |
|
233 | + foreach ($this->getParameterProperties() as $field => $getter) { |
|
235 | 234 | $result .= <<<EOF |
236 | 235 | \$this->addData('$field', \$this->param->$getter()); |
237 | 236 |
@@ -74,12 +74,12 @@ |
||
74 | 74 | ) { |
75 | 75 | parent::__construct($application, $filesystem); |
76 | 76 | $this->setName('make:crud') |
77 | - ->setDescription('Command to generate platine CRUD action'); |
|
77 | + ->setDescription('Command to generate platine CRUD action'); |
|
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * {@inheritdoc} |
|
82 | - */ |
|
80 | + /** |
|
81 | + * {@inheritdoc} |
|
82 | + */ |
|
83 | 83 | public function getClassTemplate(): string |
84 | 84 | { |
85 | 85 | return <<<EOF |
@@ -56,8 +56,7 @@ discard block |
||
56 | 56 | * @class MakeCrudActionCommand |
57 | 57 | * @package Platine\Framework\Console\Command |
58 | 58 | */ |
59 | -class MakeCrudActionCommand extends BaseMakeActionCommand |
|
60 | -{ |
|
59 | +class MakeCrudActionCommand extends BaseMakeActionCommand { |
|
61 | 60 | /** |
62 | 61 | * {@inheritdoc} |
63 | 62 | */ |
@@ -71,7 +70,7 @@ discard block |
||
71 | 70 | public function __construct( |
72 | 71 | Application $application, |
73 | 72 | Filesystem $filesystem |
74 | - ) { |
|
73 | + ) { |
|
75 | 74 | parent::__construct($application, $filesystem); |
76 | 75 | $this->setName('make:crud') |
77 | 76 | ->setDescription('Command to generate platine CRUD action'); |
@@ -159,22 +158,22 @@ discard block |
||
159 | 158 | |
160 | 159 | $replace = ''; |
161 | 160 | $fields = $this->getFieldsPropertyBody(); |
162 | - if (!empty($fields)) { |
|
161 | + if (!empty($fields)) { |
|
163 | 162 | $replace .= $fields . PHP_EOL . PHP_EOL; |
164 | 163 | } |
165 | 164 | |
166 | 165 | $orderFields = $this->getOrderByFieldsPropertyBody(); |
167 | - if (!empty($orderFields)) { |
|
166 | + if (!empty($orderFields)) { |
|
168 | 167 | $replace .= $orderFields . PHP_EOL . PHP_EOL; |
169 | 168 | } |
170 | 169 | |
171 | 170 | $uniqueFields = $this->getUniqueFieldsPropertyBody(); |
172 | - if (!empty($uniqueFields)) { |
|
171 | + if (!empty($uniqueFields)) { |
|
173 | 172 | $replace .= $uniqueFields . PHP_EOL . PHP_EOL; |
174 | 173 | } |
175 | 174 | |
176 | 175 | $templatePrefix = $this->getTemplatePrefix(); |
177 | - if (!empty($templatePrefix)) { |
|
176 | + if (!empty($templatePrefix)) { |
|
178 | 177 | $replace .= <<<EOF |
179 | 178 | /** |
180 | 179 | * {@inheritdoc} |
@@ -186,7 +185,7 @@ discard block |
||
186 | 185 | } |
187 | 186 | |
188 | 187 | $routePrefix = $this->getRoutePrefix(); |
189 | - if (!empty($routePrefix)) { |
|
188 | + if (!empty($routePrefix)) { |
|
190 | 189 | $replace .= <<<EOF |
191 | 190 | /** |
192 | 191 | * {@inheritdoc} |
@@ -199,7 +198,7 @@ discard block |
||
199 | 198 | |
200 | 199 | $entityContextName = $this->getEntityContextKey(true); |
201 | 200 | $optionEntityContext = $this->getOptionForArgument('--entity-context-key'); |
202 | - if ($optionEntityContext !== null && $optionEntityContext->getDefault() !== $entityContextName) { |
|
201 | + if ($optionEntityContext !== null && $optionEntityContext->getDefault() !== $entityContextName) { |
|
203 | 202 | $replace .= <<<EOF |
204 | 203 | /** |
205 | 204 | * {@inheritdoc} |
@@ -211,7 +210,7 @@ discard block |
||
211 | 210 | } |
212 | 211 | |
213 | 212 | $messages = $this->getMessageTemplates(); |
214 | - if (!empty($messages)) { |
|
213 | + if (!empty($messages)) { |
|
215 | 214 | $replace .= $messages; |
216 | 215 | } |
217 | 216 | |
@@ -241,13 +240,13 @@ discard block |
||
241 | 240 | 'process-error', |
242 | 241 | ]; |
243 | 242 | |
244 | - foreach ($messages as $val) { |
|
243 | + foreach ($messages as $val) { |
|
245 | 244 | $optionName = sprintf('--message-%s', $val); |
246 | 245 | $optionKey = sprintf('message%s', Str::camel($val, false)); |
247 | 246 | |
248 | 247 | $message = $this->getMessage($optionKey); |
249 | 248 | $option = $this->getOptionForArgument($optionName); |
250 | - if ($option !== null && addslashes($option->getDefault()) !== $message) { |
|
249 | + if ($option !== null && addslashes($option->getDefault()) !== $message) { |
|
251 | 250 | $replace .= <<<EOF |
252 | 251 | /** |
253 | 252 | * {@inheritdoc} |
@@ -269,7 +268,7 @@ discard block |
||
269 | 268 | protected function getFieldsPropertyBody(): string |
270 | 269 | { |
271 | 270 | $fields = $this->getOptionValue('fields'); |
272 | - if ($fields === null) { |
|
271 | + if ($fields === null) { |
|
273 | 272 | return ''; |
274 | 273 | } |
275 | 274 | |
@@ -294,7 +293,7 @@ discard block |
||
294 | 293 | { |
295 | 294 | $fields = $this->getOptionValue('fieldsOrder'); |
296 | 295 | |
297 | - if ($fields === null) { |
|
296 | + if ($fields === null) { |
|
298 | 297 | return ''; |
299 | 298 | } |
300 | 299 | |
@@ -319,7 +318,7 @@ discard block |
||
319 | 318 | { |
320 | 319 | $fields = $this->getOptionValue('fieldsUnique'); |
321 | 320 | |
322 | - if ($fields === null) { |
|
321 | + if ($fields === null) { |
|
323 | 322 | return ''; |
324 | 323 | } |
325 | 324 |
@@ -82,7 +82,7 @@ |
||
82 | 82 | ) { |
83 | 83 | parent::__construct($application, $filesystem); |
84 | 84 | $this->setName('make:enum') |
85 | - ->setDescription('Command to generate new enumeration class'); |
|
85 | + ->setDescription('Command to generate new enumeration class'); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @class MakeEnumCommand |
59 | 59 | * @package Platine\Framework\Console\Command |
60 | 60 | */ |
61 | -class MakeEnumCommand extends MakeCommand |
|
62 | -{ |
|
61 | +class MakeEnumCommand extends MakeCommand { |
|
63 | 62 | /** |
64 | 63 | * {@inheritdoc} |
65 | 64 | */ |
@@ -79,7 +78,7 @@ discard block |
||
79 | 78 | public function __construct( |
80 | 79 | Application $application, |
81 | 80 | Filesystem $filesystem |
82 | - ) { |
|
81 | + ) { |
|
83 | 82 | parent::__construct($application, $filesystem); |
84 | 83 | $this->setName('make:enum') |
85 | 84 | ->setDescription('Command to generate new enumeration class'); |
@@ -97,30 +96,30 @@ discard block |
||
97 | 96 | $io = $this->io(); |
98 | 97 | $writer->boldYellow('Enter the enumeration list (empty value to finish):', true); |
99 | 98 | $value = ''; |
100 | - while ($value !== null) { |
|
99 | + while ($value !== null) { |
|
101 | 100 | $value = $io->prompt('Enum name', null, null, false); |
102 | 101 | |
103 | - if (!empty($value)) { |
|
102 | + if (!empty($value)) { |
|
104 | 103 | $value = trim($value); |
105 | 104 | $name = preg_replace('#([^a-z0-9]+)#i', '_', $value); |
106 | - if ($name !== null && substr($name, -1) == '_') { |
|
105 | + if ($name !== null && substr($name, -1) == '_') { |
|
107 | 106 | $name = substr($name, 0, -1); |
108 | 107 | } |
109 | - if (is_string($name)) { |
|
108 | + if (is_string($name)) { |
|
110 | 109 | $properties[] = Str::upper($name); |
111 | 110 | } |
112 | 111 | } |
113 | 112 | } |
114 | 113 | |
115 | - if (!empty($properties)) { |
|
116 | - foreach ($properties as $name) { |
|
114 | + if (!empty($properties)) { |
|
115 | + foreach ($properties as $name) { |
|
117 | 116 | $value = $io->prompt( |
118 | 117 | sprintf('Enumeration value for [%s]', $name), |
119 | 118 | null, |
120 | 119 | null, |
121 | 120 | false |
122 | 121 | ); |
123 | - if (!empty($value)) { |
|
122 | + if (!empty($value)) { |
|
124 | 123 | $this->enumerations[$name] = $value; |
125 | 124 | } |
126 | 125 | } |
@@ -171,7 +170,7 @@ discard block |
||
171 | 170 | protected function getEnumerationBody(string $content): string |
172 | 171 | { |
173 | 172 | $result = ''; |
174 | - foreach ($this->enumerations as $name => $value) { |
|
173 | + foreach ($this->enumerations as $name => $value) { |
|
175 | 174 | $result .= $this->getEnumerationTemplate($name, $value); |
176 | 175 | } |
177 | 176 |
@@ -81,7 +81,7 @@ |
||
81 | 81 | ) { |
82 | 82 | parent::__construct($application, $filesystem); |
83 | 83 | $this->setName('make:repository') |
84 | - ->setDescription('Command to generate new repository class'); |
|
84 | + ->setDescription('Command to generate new repository class'); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * @class MakeRepositoryCommand |
58 | 58 | * @package Platine\Framework\Console\Command |
59 | 59 | */ |
60 | -class MakeRepositoryCommand extends MakeCommand |
|
61 | -{ |
|
60 | +class MakeRepositoryCommand extends MakeCommand { |
|
62 | 61 | /** |
63 | 62 | * {@inheritdoc} |
64 | 63 | */ |
@@ -78,7 +77,7 @@ discard block |
||
78 | 77 | public function __construct( |
79 | 78 | Application $application, |
80 | 79 | Filesystem $filesystem |
81 | - ) { |
|
80 | + ) { |
|
82 | 81 | parent::__construct($application, $filesystem); |
83 | 82 | $this->setName('make:repository') |
84 | 83 | ->setDescription('Command to generate new repository class'); |
@@ -95,7 +94,7 @@ discard block |
||
95 | 94 | $io = $this->io(); |
96 | 95 | |
97 | 96 | $entityClass = $io->prompt('Enter the entity full class name', null); |
98 | - while (!class_exists($entityClass)) { |
|
97 | + while (!class_exists($entityClass)) { |
|
99 | 98 | $entityClass = $io->prompt('Class does not exists, please enter the entity full class name', null); |
100 | 99 | } |
101 | 100 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($application, $filesystem); |
75 | 75 | $this->setName('make:middleware') |
76 | - ->setDescription('Command to generate new middleware class'); |
|
76 | + ->setDescription('Command to generate new middleware class'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * @class MakeMiddlewareCommand |
56 | 56 | * @package Platine\Framework\Console\Command |
57 | 57 | */ |
58 | -class MakeMiddlewareCommand extends MakeCommand |
|
59 | -{ |
|
58 | +class MakeMiddlewareCommand extends MakeCommand { |
|
60 | 59 | /** |
61 | 60 | * {@inheritdoc} |
62 | 61 | */ |
@@ -70,7 +69,7 @@ discard block |
||
70 | 69 | public function __construct( |
71 | 70 | Application $application, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($application, $filesystem); |
75 | 74 | $this->setName('make:middleware') |
76 | 75 | ->setDescription('Command to generate new middleware class'); |
@@ -76,7 +76,7 @@ |
||
76 | 76 | ) { |
77 | 77 | parent::__construct($application, $filesystem); |
78 | 78 | $this->setName('make:action') |
79 | - ->setDescription('Command to generate new request handler class'); |
|
79 | + ->setDescription('Command to generate new request handler class'); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @class MakeActionCommand |
59 | 59 | * @package Platine\Framework\Console\Command |
60 | 60 | */ |
61 | -class MakeActionCommand extends MakeCommand |
|
62 | -{ |
|
61 | +class MakeActionCommand extends MakeCommand { |
|
63 | 62 | /** |
64 | 63 | * {@inheritdoc} |
65 | 64 | */ |
@@ -73,7 +72,7 @@ discard block |
||
73 | 72 | public function __construct( |
74 | 73 | Application $application, |
75 | 74 | Filesystem $filesystem |
76 | - ) { |
|
75 | + ) { |
|
77 | 76 | parent::__construct($application, $filesystem); |
78 | 77 | $this->setName('make:action') |
79 | 78 | ->setDescription('Command to generate new request handler class'); |
@@ -91,14 +90,14 @@ discard block |
||
91 | 90 | $io = $this->io(); |
92 | 91 | $writer->boldYellow('Enter the properties list (empty value to finish):', true); |
93 | 92 | $value = ''; |
94 | - while ($value !== null) { |
|
93 | + while ($value !== null) { |
|
95 | 94 | $value = $io->prompt('Property full class name', null, null, false); |
96 | 95 | |
97 | - if (!empty($value)) { |
|
96 | + if (!empty($value)) { |
|
98 | 97 | $value = trim($value); |
99 | - if (!class_exists($value) && !interface_exists($value)) { |
|
98 | + if (!class_exists($value) && !interface_exists($value)) { |
|
100 | 99 | $writer->boldWhiteBgRed(sprintf('The class [%s] does not exists', $value), true); |
101 | - } else { |
|
100 | + } else { |
|
102 | 101 | $shortClass = $this->getClassBaseName($value); |
103 | 102 | $name = Str::camel($shortClass, true); |
104 | 103 | //replace"interface", "abstract" |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $this->config = $config; |
86 | 86 | |
87 | 87 | $this->setName('maintenance') |
88 | - ->setDescription('Command to manage application maintenance'); |
|
88 | + ->setDescription('Command to manage application maintenance'); |
|
89 | 89 | |
90 | 90 | $this->addArgument('type', 'type of action [up|down|status]', 'status', true, true, false, function ($val) { |
91 | 91 | if (!in_array($val, ['up', 'down', 'status'])) { |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | )); |
96 | 96 | } |
97 | 97 | |
98 | - return $val; |
|
98 | + return $val; |
|
99 | 99 | }); |
100 | 100 | |
101 | 101 | $this->addOption( |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $this->setName('maintenance') |
88 | 88 | ->setDescription('Command to manage application maintenance'); |
89 | 89 | |
90 | - $this->addArgument('type', 'type of action [up|down|status]', 'status', true, true, false, function ($val) { |
|
90 | + $this->addArgument('type', 'type of action [up|down|status]', 'status', true, true, false, function($val) { |
|
91 | 91 | if (!in_array($val, ['up', 'down', 'status'])) { |
92 | 92 | throw new RuntimeException(sprintf( |
93 | 93 | 'Invalid argument type [%s], must be one of [up, down, status]', |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | false, |
114 | 114 | true, |
115 | 115 | false, |
116 | - function ($val) { |
|
116 | + function($val) { |
|
117 | 117 | if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
118 | 118 | throw new RuntimeException(sprintf( |
119 | 119 | 'Invalid retry value [%s], must be an integer greather than zero', |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | false, |
132 | 132 | true, |
133 | 133 | false, |
134 | - function ($val) { |
|
134 | + function($val) { |
|
135 | 135 | if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
136 | 136 | throw new RuntimeException(sprintf( |
137 | 137 | 'Invalid refresh value [%s], must be an integer greather than zero', |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | false, |
157 | 157 | true, |
158 | 158 | false, |
159 | - function ($val) { |
|
159 | + function($val) { |
|
160 | 160 | if (strlen($val) > 0 && (!is_numeric($val) || (int) $val < 200 || (int) $val > 505)) { |
161 | 161 | throw new RuntimeException(sprintf( |
162 | 162 | 'Invalid HTTP status value [%s], must be between 200 and 505', |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * @package Platine\Framework\Console\Command |
59 | 59 | * @template T |
60 | 60 | */ |
61 | -class MaintenanceCommand extends Command |
|
62 | -{ |
|
61 | +class MaintenanceCommand extends Command { |
|
63 | 62 | /** |
64 | 63 | * The configuration to use |
65 | 64 | * @var Config<T> |
@@ -80,15 +79,15 @@ discard block |
||
80 | 79 | public function __construct( |
81 | 80 | Application $app, |
82 | 81 | Config $config |
83 | - ) { |
|
82 | + ) { |
|
84 | 83 | $this->application = $app; |
85 | 84 | $this->config = $config; |
86 | 85 | |
87 | 86 | $this->setName('maintenance') |
88 | 87 | ->setDescription('Command to manage application maintenance'); |
89 | 88 | |
90 | - $this->addArgument('type', 'type of action [up|down|status]', 'status', true, true, false, function ($val) { |
|
91 | - if (!in_array($val, ['up', 'down', 'status'])) { |
|
89 | + $this->addArgument('type', 'type of action [up|down|status]', 'status', true, true, false, function ($val) { |
|
90 | + if (!in_array($val, ['up', 'down', 'status'])) { |
|
92 | 91 | throw new RuntimeException(sprintf( |
93 | 92 | 'Invalid argument type [%s], must be one of [up, down, status]', |
94 | 93 | $val |
@@ -113,8 +112,8 @@ discard block |
||
113 | 112 | false, |
114 | 113 | true, |
115 | 114 | false, |
116 | - function ($val) { |
|
117 | - if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
|
115 | + function ($val) { |
|
116 | + if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
|
118 | 117 | throw new RuntimeException(sprintf( |
119 | 118 | 'Invalid retry value [%s], must be an integer greather than zero', |
120 | 119 | $val |
@@ -131,8 +130,8 @@ discard block |
||
131 | 130 | false, |
132 | 131 | true, |
133 | 132 | false, |
134 | - function ($val) { |
|
135 | - if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
|
133 | + function ($val) { |
|
134 | + if (strlen($val) > 0 && (!is_numeric($val) || (int) $val <= 0)) { |
|
136 | 135 | throw new RuntimeException(sprintf( |
137 | 136 | 'Invalid refresh value [%s], must be an integer greather than zero', |
138 | 137 | $val |
@@ -156,8 +155,8 @@ discard block |
||
156 | 155 | false, |
157 | 156 | true, |
158 | 157 | false, |
159 | - function ($val) { |
|
160 | - if (strlen($val) > 0 && (!is_numeric($val) || (int) $val < 200 || (int) $val > 505)) { |
|
158 | + function ($val) { |
|
159 | + if (strlen($val) > 0 && (!is_numeric($val) || (int) $val < 200 || (int) $val > 505)) { |
|
161 | 160 | throw new RuntimeException(sprintf( |
162 | 161 | 'Invalid HTTP status value [%s], must be between 200 and 505', |
163 | 162 | $val |
@@ -179,19 +178,18 @@ discard block |
||
179 | 178 | /** |
180 | 179 | * {@inheritdoc} |
181 | 180 | */ |
182 | - public function execute() |
|
183 | - { |
|
181 | + public function execute() { |
|
184 | 182 | $type = $this->getArgumentValue('type'); |
185 | 183 | |
186 | 184 | $io = $this->io(); |
187 | 185 | $writer = $io->writer(); |
188 | 186 | $writer->boldYellow('APPLICATION MAINTENANCE MANAGEMENT', true)->eol(); |
189 | 187 | |
190 | - if ($type === 'up') { |
|
188 | + if ($type === 'up') { |
|
191 | 189 | $this->online(); |
192 | - } elseif ($type === 'down') { |
|
190 | + } elseif ($type === 'down') { |
|
193 | 191 | $this->down(); |
194 | - } else { |
|
192 | + } else { |
|
195 | 193 | $this->status(); |
196 | 194 | } |
197 | 195 | } |
@@ -204,8 +202,8 @@ discard block |
||
204 | 202 | { |
205 | 203 | $writer = $this->io()->writer(); |
206 | 204 | |
207 | - try { |
|
208 | - if ($this->application->isInMaintenance() === false) { |
|
205 | + try { |
|
206 | + if ($this->application->isInMaintenance() === false) { |
|
209 | 207 | $writer->boldRed('Application already online')->eol(); |
210 | 208 | return; |
211 | 209 | } |
@@ -213,7 +211,7 @@ discard block |
||
213 | 211 | $this->application->maintenance()->deactivate(); |
214 | 212 | |
215 | 213 | $writer->boldGreen('Application is now online')->eol(); |
216 | - } catch (Throwable $ex) { |
|
214 | + } catch (Throwable $ex) { |
|
217 | 215 | $writer->boldRed(sprintf( |
218 | 216 | 'Failed to disable maintenance mode: %s.', |
219 | 217 | $ex->getMessage() |
@@ -229,8 +227,8 @@ discard block |
||
229 | 227 | { |
230 | 228 | $writer = $this->io()->writer(); |
231 | 229 | |
232 | - try { |
|
233 | - if ($this->application->isInMaintenance()) { |
|
230 | + try { |
|
231 | + if ($this->application->isInMaintenance()) { |
|
234 | 232 | $writer->boldRed('Application is already down.')->eol(); |
235 | 233 | return; |
236 | 234 | } |
@@ -239,7 +237,7 @@ discard block |
||
239 | 237 | $this->application->maintenance()->activate($data); |
240 | 238 | |
241 | 239 | $writer->boldGreen('Application is now in maintenance mode.')->eol(); |
242 | - } catch (Throwable $ex) { |
|
240 | + } catch (Throwable $ex) { |
|
243 | 241 | $writer->boldRed(sprintf( |
244 | 242 | 'Failed to enable maintenance mode: %s.', |
245 | 243 | $ex->getMessage() |
@@ -255,9 +253,9 @@ discard block |
||
255 | 253 | { |
256 | 254 | $writer = $this->io()->writer(); |
257 | 255 | |
258 | - if ($this->application->isInMaintenance()) { |
|
256 | + if ($this->application->isInMaintenance()) { |
|
259 | 257 | $writer->boldYellow('Application is down.')->eol(); |
260 | - } else { |
|
258 | + } else { |
|
261 | 259 | $writer->boldGreen('Application is online.')->eol(); |
262 | 260 | } |
263 | 261 | } |
@@ -269,17 +267,17 @@ discard block |
||
269 | 267 | protected function getPayload(): array |
270 | 268 | { |
271 | 269 | $retry = $this->getOptionValue('retry') ?? 3600; |
272 | - if ($retry) { |
|
270 | + if ($retry) { |
|
273 | 271 | $retry = (int) $retry; |
274 | 272 | } |
275 | 273 | |
276 | 274 | $refresh = $this->getOptionValue('refresh') ?? 3600; |
277 | - if ($refresh) { |
|
275 | + if ($refresh) { |
|
278 | 276 | $refresh = (int) $refresh; |
279 | 277 | } |
280 | 278 | |
281 | 279 | $status = $this->getOptionValue('status') ?? 503; |
282 | - if ($status) { |
|
280 | + if ($status) { |
|
283 | 281 | $status = (int) $status; |
284 | 282 | } |
285 | 283 |
@@ -73,7 +73,7 @@ |
||
73 | 73 | ) { |
74 | 74 | parent::__construct($application, $filesystem); |
75 | 75 | $this->setName('make:event') |
76 | - ->setDescription('Command to generate new event class'); |
|
76 | + ->setDescription('Command to generate new event class'); |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | /** |
@@ -55,8 +55,7 @@ discard block |
||
55 | 55 | * @class MakeEventCommand |
56 | 56 | * @package Platine\Framework\Console\Command |
57 | 57 | */ |
58 | -class MakeEventCommand extends MakeCommand |
|
59 | -{ |
|
58 | +class MakeEventCommand extends MakeCommand { |
|
60 | 59 | /** |
61 | 60 | * {@inheritdoc} |
62 | 61 | */ |
@@ -70,7 +69,7 @@ discard block |
||
70 | 69 | public function __construct( |
71 | 70 | Application $application, |
72 | 71 | Filesystem $filesystem |
73 | - ) { |
|
72 | + ) { |
|
74 | 73 | parent::__construct($application, $filesystem); |
75 | 74 | $this->setName('make:event') |
76 | 75 | ->setDescription('Command to generate new event class'); |