@@ 230-247 (lines=18) @@ | ||
227 | * @param string $type |
|
228 | * @return ClassGenerator |
|
229 | */ |
|
230 | public function generateListSet(string $name, string $type): ClassGenerator |
|
231 | { |
|
232 | $this->class |
|
233 | ->addMethod(static::camelCase('set_' . $name)) |
|
234 | ->addComment( |
|
235 | '@param ' . $this->getCommentTypeHint($type) . ' $values' . PHP_EOL . |
|
236 | '@return ' . $this->class->getName() |
|
237 | )->setReturnType($this->getCanonicalClassName()) |
|
238 | ->setBody( |
|
239 | '$this->' . static::camelCase('clear_' . $name) . '();' . PHP_EOL . |
|
240 | 'foreach ($values as $value) {' . PHP_EOL . |
|
241 | ' $this->' . static::camelCase('push_' . $name) . '($value);' . PHP_EOL . |
|
242 | '}' . PHP_EOL . |
|
243 | 'return $this;' |
|
244 | )->addParameter('values') |
|
245 | ->setTypeHint($this->getTypeHint($type)); |
|
246 | return $this; |
|
247 | } |
|
248 | ||
249 | /** |
|
250 | * @param string $name |
|
@@ 358-375 (lines=18) @@ | ||
355 | * @param string $type |
|
356 | * @return ClassGenerator |
|
357 | */ |
|
358 | public function generateMapSet(string $name, string $type): ClassGenerator |
|
359 | { |
|
360 | $this->class |
|
361 | ->addMethod(static::camelCase('set_' . $name)) |
|
362 | ->addComment( |
|
363 | '@param ' . $this->getCommentTypeHint($type) . ' $values' . PHP_EOL . |
|
364 | '@return ' . $this->class->getName() |
|
365 | )->setReturnType($this->getCanonicalClassName()) |
|
366 | ->setBody( |
|
367 | '$this->' . static::camelCase('clear_' . $name) . '();' . PHP_EOL . |
|
368 | 'foreach ($values as $key => $value) {' . PHP_EOL . |
|
369 | ' $this->' . static::camelCase('set_' . $name . '_at') . '($key, $value);' . PHP_EOL . |
|
370 | '}' . PHP_EOL . |
|
371 | 'return $this;' |
|
372 | )->addParameter('values') |
|
373 | ->setTypeHint($this->getTypeHint($type)); |
|
374 | return $this; |
|
375 | } |
|
376 | ||
377 | /** |
|
378 | * @param string $name |