/**
  * @covers ::convertReflectionMethod
  */
 public function testConvertReflectionMethod()
 {
     $reflectionClass = new \ReflectionClass($this);
     $method = $reflectionClass->getMethod('dummyMethod');
     /* @var ClassMethod $classMethod */
     $this->classMethod->convertReflectionMethod($method);
     $methodParams = $this->classMethod->getParameters();
     $this->assertInstanceOf('\\Classes\\MethodParameter', $methodParams[0]);
 }
    /**
     * @return ClassMethod
     */
    protected function generateAdd()
    {
        $setter = new ClassMethod('add' . ucfirst($this->classProperty->getName()));
        $setter->setDescription('Add item to ' . $this->classProperty->getName());
        $setterParam = new MethodParameter($this->classProperty->getName(), 'mixed');
        $setter->addParameter($setterParam);
        $body = <<<BODY
\t\$this->{$this->classProperty->getName()} = \${$this->classProperty->getName()};
BODY;
        $setter->setBody($body);
        return $setter;
    }
 /**
  * @Route("/testclass", name="homepage")
  *
  * @Method("GET")
  */
 public function indexAction()
 {
     $class = new BaseClass('Classes', 'BestClass');
     $class->addProperty(new ClassProperty('test', 'string'));
     $method = new ClassMethod('setTest');
     $method->addParameter(new MethodParameter('test', 'string'));
     $method->setReturnType(null);
     $class->addMethod($method);
     $classGenerator = new ClassGenerator($class);
     $classWriter = new ClassWriter($classGenerator, new Filesystem(), '/Users/justingriffith/Sites/CodeCreator/');
     $classWriter->write();
     return $this->render('default/index.html.twig');
 }
 /**
  * @return string
  */
 protected function generateParameters()
 {
     $params = [];
     foreach ($this->classMethod->getParameters() as $parameter) {
         $param = !$parameter->isPrimitive() ? $parameter->getType() . ' ' : '';
         $params[] = $param . '$' . $parameter->getName();
     }
     return implode(', ', $params);
 }
 /**
  * @param array $methods
  *
  * @return array
  */
 private function translateMethodsToClassMethod(array $methods)
 {
     $result = [];
     foreach ($methods as $key => $method) {
         $method = (object) $method;
         $classMethod = new ClassMethod($key);
         if (isset($method->parameters)) {
             foreach ($method->parameters as $paramKey => $param) {
                 $classMethod->addParameter(new MethodParameter($paramKey, $param['type']));
             }
         }
         $result[] = $classMethod;
     }
     return $result;
 }
 protected function generateImplementMethods()
 {
     $output = '';
     foreach ($this->baseClass->getImplements() as $implement) {
         $reflection = new \ReflectionClass($implement);
         foreach ($reflection->getMethods() as $method) {
             $implementor = new ClassMethod($method->name, $method);
             $implementor->setDescription('Implementation of ' . $method->getName() . ' interface method');
             $implementor->setBody(' // TODO: Code implementation');
             $output .= PHP_EOL . $implementor->generate() . PHP_EOL;
         }
     }
     return $output;
 }