Example #1
0
 /**
  * @param ClassGenerator $class
  * @param Property       $firstProperty
  *
  * @throws \Zend\Code\Generator\Exception\InvalidArgumentException
  */
 private function implementGetIterator($class, $firstProperty)
 {
     $methodName = 'getIterator';
     $class->removeMethod($methodName);
     $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => sprintf('return new \\ArrayIterator(is_array($this->%1$s) ? $this->%1$s : []);', $firstProperty->getName()), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => '\\ArrayIterator']]])]));
 }
 /**
  * @param Property $property
  *
  * @return string
  */
 private function generateGetResultReturnTag(Property $property)
 {
     if ($this->wrapperClass === null) {
         return $property->getType() . '|' . Normalizer::getClassNameFromFQN(ResultInterface::class);
     }
     return Normalizer::getClassNameFromFQN($this->wrapperClass);
 }