@@ -28,7 +28,7 @@ |
||
28 | 28 | $this->setDispatcher($dispatcher); |
29 | 29 | $this->keekoDispatcher = $dispatcher; |
30 | 30 | |
31 | - $dispatcher->addListener(ConsoleEvents::TERMINATE, function (ConsoleTerminateEvent $event) { |
|
31 | + $dispatcher->addListener(ConsoleEvents::TERMINATE, function(ConsoleTerminateEvent $event) { |
|
32 | 32 | $command = $event->getCommand(); |
33 | 33 | $this->finishedCommands[] = $command->getName(); |
34 | 34 | }); |
@@ -24,8 +24,7 @@ |
||
24 | 24 | */ |
25 | 25 | protected function getQuestion($question, $default = null, $sep = ':') { |
26 | 26 | return !empty($default) ? |
27 | - sprintf('<info>%s</info> [<comment>%s</comment>]%s ', $question, $default, $sep) : |
|
28 | - sprintf('<info>%s</info>%s ', $question, $sep); |
|
27 | + sprintf('<info>%s</info> [<comment>%s</comment>]%s ', $question, $default, $sep) : sprintf('<info>%s</info>%s ', $question, $sep); |
|
29 | 28 | } |
30 | 29 | |
31 | 30 | /** |
@@ -6,6 +6,6 @@ |
||
6 | 6 | public function __construct() {} |
7 | 7 | |
8 | 8 | public function getTemplateRoot() { |
9 | - return __DIR__ . '/../../templates'; |
|
9 | + return __DIR__.'/../../templates'; |
|
10 | 10 | } |
11 | 11 | } |
12 | 12 | \ No newline at end of file |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | protected function initialize(InputInterface $input, OutputInterface $output) { |
55 | 55 | parent::initialize($input, $output); |
56 | 56 | |
57 | - $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot() . '/domain'); |
|
57 | + $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot().'/domain'); |
|
58 | 58 | $this->twig = new \Twig_Environment($loader); |
59 | 59 | } |
60 | 60 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | } |
151 | 151 | |
152 | 152 | private function generateModel($modelName) { |
153 | - $this->logger->info('Generate Domain from Model: ' . $modelName); |
|
153 | + $this->logger->info('Generate Domain from Model: '.$modelName); |
|
154 | 154 | $model = $this->modelService->getModel($modelName); |
155 | 155 | |
156 | 156 | // generate class |
@@ -123,14 +123,14 @@ discard block |
||
123 | 123 | if (!empty($localName)) { |
124 | 124 | $name = $this->package->getFullName(); |
125 | 125 | } else if (isset($git['github.user'])) { |
126 | - $name = $git['github.user'] . '/' . $name; |
|
126 | + $name = $git['github.user'].'/'.$name; |
|
127 | 127 | } elseif (!empty($_SERVER['USERNAME'])) { |
128 | - $name = $_SERVER['USERNAME'] . '/' . $name; |
|
128 | + $name = $_SERVER['USERNAME'].'/'.$name; |
|
129 | 129 | } elseif (get_current_user()) { |
130 | - $name = get_current_user() . '/' . $name; |
|
130 | + $name = get_current_user().'/'.$name; |
|
131 | 131 | } else { |
132 | 132 | // package names must be in the format foo/bar |
133 | - $name = $name . '/' . $name; |
|
133 | + $name = $name.'/'.$name; |
|
134 | 134 | } |
135 | 135 | } else { |
136 | 136 | $this->validateName($name); |
@@ -171,9 +171,9 @@ discard block |
||
171 | 171 | $types = ['module', 'app']; |
172 | 172 | $question = new Question('Package type (module|app)', $type); |
173 | 173 | $question->setAutocompleterValues($types); |
174 | - $question->setValidator(function ($answer) use ($types) { |
|
174 | + $question->setValidator(function($answer) use ($types) { |
|
175 | 175 | if (!in_array($answer, $types)) { |
176 | - throw new \RuntimeException('The name of the type should be one of: ' . |
|
176 | + throw new \RuntimeException('The name of the type should be one of: '. |
|
177 | 177 | implode(',', $types)); |
178 | 178 | } |
179 | 179 | return $answer; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | // KEEKO values |
205 | 205 | $output->writeln([ |
206 | 206 | '', |
207 | - 'Information for Keeko ' . ucfirst($type), |
|
207 | + 'Information for Keeko '.ucfirst($type), |
|
208 | 208 | '' |
209 | 209 | ]); |
210 | 210 | |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | // type |
260 | 260 | if (($type = $input->getOption('type')) !== null) { |
261 | 261 | if (in_array($type, ['app', 'module'])) { |
262 | - $this->package->setType('keeko-' . $type); |
|
262 | + $this->package->setType('keeko-'.$type); |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
@@ -368,7 +368,7 @@ discard block |
||
368 | 368 | $package = $this->package->getKeeko()->getKeekoPackage($type); |
369 | 369 | $fqcn = str_replace(['\\', 'keeko-', '-module', '-app'], ['/', '', '', ''], $package->getClass()); |
370 | 370 | $classname = basename($fqcn); |
371 | - $filename = $this->project->getRootPath() . '/src/' . $classname . '.php'; |
|
371 | + $filename = $this->project->getRootPath().'/src/'.$classname.'.php'; |
|
372 | 372 | $fqcn = str_replace('/', '\\', $fqcn); |
373 | 373 | |
374 | 374 | if (!file_exists($filename) || $input->getOption('force')) { |
@@ -499,7 +499,7 @@ discard block |
||
499 | 499 | $parts = explode('/', $pkgName); |
500 | 500 | $ns = $input->getOption('namespace'); |
501 | 501 | $namespace = !empty($ns) ? $ns : str_replace('/', '\\', $pkgName); |
502 | - $classname = $namespace . '\\' . ucfirst($parts[1]); |
|
502 | + $classname = $namespace.'\\'.ucfirst($parts[1]); |
|
503 | 503 | |
504 | 504 | // suffix |
505 | 505 | if ($type === 'module') { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function initialize(InputInterface $input, OutputInterface $output) { |
47 | 47 | parent::initialize($input, $output); |
48 | 48 | |
49 | - $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot() . '/serializer'); |
|
49 | + $loader = new \Twig_Loader_Filesystem($this->service->getConfig()->getTemplateRoot().'/serializer'); |
|
50 | 50 | $this->twig = new \Twig_Environment($loader); |
51 | 51 | } |
52 | 52 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | } |
134 | 134 | |
135 | 135 | private function generateModel($modelName) { |
136 | - $this->logger->info('Generate Serializer from Model: ' . $modelName); |
|
136 | + $this->logger->info('Generate Serializer from Model: '.$modelName); |
|
137 | 137 | $model = $this->modelService->getModel($modelName); |
138 | 138 | |
139 | 139 | // trait |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | $this->codegenService->dumpStruct($serializer, true); |
162 | 162 | |
163 | 163 | // add serializer + APIModelInterface on the model |
164 | - $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace() . '\\' . $model->getPhpName())); |
|
164 | + $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace().'\\'.$model->getPhpName())); |
|
165 | 165 | $file = new File($this->codegenService->getFilename($class)); |
166 | 166 | if ($file->exists()) { |
167 | 167 | $class = PhpClass::fromFile($this->codegenService->getFilename($class)); |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * @param string $actionName |
192 | 192 | */ |
193 | 193 | private function generateAction($actionName) { |
194 | - $this->logger->info('Generate Serializer for action: ' . $actionName); |
|
194 | + $this->logger->info('Generate Serializer for action: '.$actionName); |
|
195 | 195 | |
196 | 196 | $action = $this->packageService->getAction($actionName); |
197 | 197 | $generator = new ActionSerializerGenerator($this->service); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | |
62 | 62 | $module = $this->package->getKeeko()->getModule(); |
63 | 63 | $swagger->setVersion('2.0'); |
64 | - $swagger->getInfo()->setTitle($module->getTitle() . ' API'); |
|
64 | + $swagger->getInfo()->setTitle($module->getTitle().' API'); |
|
65 | 65 | $swagger->getTags()->clear(); |
66 | 66 | $swagger->getTags()->add(new Tag(['name' => $module->getSlug()])); |
67 | 67 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | foreach ($models as $modelName) { |
83 | 83 | $tableName = $this->modelService->getTableName($modelName); |
84 | 84 | $model = $this->modelService->getModel($tableName); |
85 | - $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace() . '\\' . $model->getPhpName())); |
|
85 | + $class = new PhpClass(str_replace('\\\\', '\\', $model->getNamespace().'\\'.$model->getPhpName())); |
|
86 | 86 | $file = new File($this->codegenService->getFilename($class)); |
87 | 87 | |
88 | 88 | if ($file->exists()) { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | } |
111 | 111 | |
112 | 112 | protected function generateOperation(Paths $paths, $actionName) { |
113 | - $this->logger->notice('Generating Operation for: ' . $actionName); |
|
113 | + $this->logger->notice('Generating Operation for: '.$actionName); |
|
114 | 114 | |
115 | 115 | if (Text::create($actionName)->contains('relationship')) { |
116 | 116 | $this->generateRelationshipOperation($paths, $actionName); |
@@ -120,18 +120,18 @@ discard block |
||
120 | 120 | } |
121 | 121 | |
122 | 122 | protected function generateRelationshipOperation(Paths $paths, $actionName) { |
123 | - $this->logger->notice('Generating Relationship Operation for: ' . $actionName); |
|
123 | + $this->logger->notice('Generating Relationship Operation for: '.$actionName); |
|
124 | 124 | $prefix = substr($actionName, 0, strrpos($actionName, 'relationship') + 12); |
125 | 125 | $module = $this->packageService->getModule(); |
126 | 126 | |
127 | 127 | // test for to-many relationship: |
128 | - $many = $module->hasAction($prefix . '-read') |
|
129 | - && $module->hasAction($prefix . '-update') |
|
130 | - && $module->hasAction($prefix . '-add') |
|
131 | - && $module->hasAction($prefix . '-remove') |
|
128 | + $many = $module->hasAction($prefix.'-read') |
|
129 | + && $module->hasAction($prefix.'-update') |
|
130 | + && $module->hasAction($prefix.'-add') |
|
131 | + && $module->hasAction($prefix.'-remove') |
|
132 | 132 | ; |
133 | - $single = $module->hasAction($prefix . '-read') |
|
134 | - && $module->hasAction($prefix . '-update') |
|
133 | + $single = $module->hasAction($prefix.'-read') |
|
134 | + && $module->hasAction($prefix.'-update') |
|
135 | 135 | && !$many |
136 | 136 | ; |
137 | 137 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $action = $this->packageService->getAction($actionName); |
160 | 160 | $type = substr($actionName, strrpos($actionName, '-') + 1); |
161 | 161 | $method = $this->getMethod($type); |
162 | - $endpoint = '/' . NameUtils::pluralize($modelName) . '/{id}/relationship/' . ($single ? |
|
162 | + $endpoint = '/'.NameUtils::pluralize($modelName).'/{id}/relationship/'.($single ? |
|
163 | 163 | $foreignModelName : NameUtils::pluralize($foreignModelName)); |
164 | 164 | |
165 | 165 | $path = $paths->get($endpoint); |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | } |
191 | 191 | |
192 | 192 | protected function generateCRUDOperation(Paths $paths, $actionName) { |
193 | - $this->logger->notice('Generating CRUD Operation for: ' . $actionName); |
|
193 | + $this->logger->notice('Generating CRUD Operation for: '.$actionName); |
|
194 | 194 | $database = $this->modelService->getDatabase(); |
195 | 195 | $action = $this->packageService->getAction($actionName); |
196 | 196 | $modelName = $this->modelService->getModelNameByAction($action); |
@@ -208,13 +208,13 @@ discard block |
||
208 | 208 | switch ($type) { |
209 | 209 | case 'list': |
210 | 210 | case 'create': |
211 | - $endpoint = '/' . $modelPluralName; |
|
211 | + $endpoint = '/'.$modelPluralName; |
|
212 | 212 | break; |
213 | 213 | |
214 | 214 | case 'read': |
215 | 215 | case 'update': |
216 | 216 | case 'delete': |
217 | - $endpoint = '/' . $modelPluralName . '/{id}'; |
|
217 | + $endpoint = '/'.$modelPluralName.'/{id}'; |
|
218 | 218 | break; |
219 | 219 | |
220 | 220 | default: |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | case 'list': |
238 | 238 | $ok = $responses->get('200'); |
239 | 239 | $ok->setDescription(sprintf('Array of %s', $modelPluralName)); |
240 | - $ok->getSchema()->setRef('#/definitions/' . 'Paged' . NameUtils::pluralize($modelObjectName)); |
|
240 | + $ok->getSchema()->setRef('#/definitions/'.'Paged'.NameUtils::pluralize($modelObjectName)); |
|
241 | 241 | break; |
242 | 242 | |
243 | 243 | case 'create': |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | $body->setIn('body'); |
248 | 248 | $body->setDescription(sprintf('The new %s', $modelName)); |
249 | 249 | $body->setRequired(true); |
250 | - $body->getSchema()->setRef('#/definitions/Writable' . $modelObjectName); |
|
250 | + $body->getSchema()->setRef('#/definitions/Writable'.$modelObjectName); |
|
251 | 251 | |
252 | 252 | // response |
253 | 253 | $ok = $responses->get('201'); |
@@ -258,14 +258,14 @@ discard block |
||
258 | 258 | // response |
259 | 259 | $ok = $responses->get('200'); |
260 | 260 | $ok->setDescription(sprintf('gets the %s', $modelName)); |
261 | - $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
261 | + $ok->getSchema()->setRef('#/definitions/'.$modelObjectName); |
|
262 | 262 | break; |
263 | 263 | |
264 | 264 | case 'update': |
265 | 265 | // response |
266 | 266 | $ok = $responses->get('200'); |
267 | 267 | $ok->setDescription(sprintf('%s updated', $modelName)); |
268 | - $ok->getSchema()->setRef('#/definitions/' . $modelObjectName); |
|
268 | + $ok->getSchema()->setRef('#/definitions/'.$modelObjectName); |
|
269 | 269 | break; |
270 | 270 | |
271 | 271 | case 'delete': |
@@ -352,19 +352,19 @@ discard block |
||
352 | 352 | } |
353 | 353 | |
354 | 354 | protected function generateDefinition(Definitions $definitions, Table $model) { |
355 | - $this->logger->notice('Generating Definition for: ' . $model->getOriginCommonName()); |
|
355 | + $this->logger->notice('Generating Definition for: '.$model->getOriginCommonName()); |
|
356 | 356 | $modelObjectName = $model->getPhpName(); |
357 | 357 | |
358 | 358 | // paged model |
359 | - $pagedModel = 'Paged' . NameUtils::pluralize($modelObjectName); |
|
359 | + $pagedModel = 'Paged'.NameUtils::pluralize($modelObjectName); |
|
360 | 360 | $paged = $definitions->get($pagedModel)->setType('object')->getProperties(); |
361 | 361 | $paged->get('data') |
362 | 362 | ->setType('array') |
363 | - ->getItems()->setRef('#/definitions/' . $modelObjectName); |
|
363 | + ->getItems()->setRef('#/definitions/'.$modelObjectName); |
|
364 | 364 | $paged->get('meta')->setRef('#/definitions/PagedMeta'); |
365 | 365 | |
366 | 366 | // writable model |
367 | - $writable = $definitions->get('Writable' . $modelObjectName)->setType('object')->getProperties(); |
|
367 | + $writable = $definitions->get('Writable'.$modelObjectName)->setType('object')->getProperties(); |
|
368 | 368 | $this->generateModelProperties($writable, $model, true); |
369 | 369 | |
370 | 370 | // readable model |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | |
18 | 18 | public function getCodegenFile() { |
19 | 19 | $basepath = dirname($this->project->getComposerFileName()); |
20 | - return $basepath . '/codegen.json'; |
|
20 | + return $basepath.'/codegen.json'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | $jsonFile = $this->project->getComposerFileName(); |
230 | 230 | $path = new Path(dirname($jsonFile)); |
231 | 231 | $path = $path->append($relativeSourcePath); |
232 | - $path = $path->append($struct->getName() . '.php'); |
|
232 | + $path = $path->append($struct->getName().'.php'); |
|
233 | 233 | return $path->toString(); |
234 | 234 | } |
235 | 235 |
@@ -15,9 +15,9 @@ |
||
15 | 15 | |
16 | 16 | // method: run(Request $request) |
17 | 17 | $class->addUseStatement('Tobscure\\JsonApi\\Parameters'); |
18 | - $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()) . '\\' . $model->getPhpName() . 'Domain'); |
|
18 | + $class->addUseStatement(str_replace('model', 'domain', $model->getNamespace()).'\\'.$model->getPhpName().'Domain'); |
|
19 | 19 | $class->setMethod($this->generateRunMethod($this->twig->render('list-run.twig', [ |
20 | - 'domain' => $model->getPhpName() . 'Domain' |
|
20 | + 'domain' => $model->getPhpName().'Domain' |
|
21 | 21 | ]))); |
22 | 22 | |
23 | 23 | } |