public function getNode(ImprovedClassSource $classSource)
 {
     //Namespace
     $code = $this->builderFactory->namespace($classSource->getNamespace());
     //Adds use to header of file
     foreach ($classSource->getImports() as $import) {
         $code->addStmt($this->builderFactory->use($import->getFullName()));
     }
     $classCode = $this->classGenerator->generate($classSource);
     foreach ($classSource->getMethods() as $method) {
         $result = $this->methodFactory->generate($method);
         $classCode->addStmt($result);
     }
     $code->addStmt($classCode);
     return $code->getNode();
 }
 /**
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function generate(ImprovedClassSource $improvedClassSource)
 {
     $specClassType = ClassType::create('spec\\' . $improvedClassSource->getClassType()->getFullName() . 'Spec');
     $specSource = $this->factory->create($specClassType);
     foreach ($improvedClassSource->getImports() as $import) {
         if (false === $import instanceof TraitType) {
             $specSource->addImport($import);
         }
     }
     $specSource->addImport($improvedClassSource->getClassType());
     $specSource->addImport(ClassType::create('Prophecy\\Argument'));
     $specSource->addParent(ClassType::create('PhpSpec\\ObjectBehavior'));
     $initializable = [$improvedClassSource->getClassType()];
     if ($improvedClassSource->hasParent()) {
         $initializable[] = $improvedClassSource->getParent();
     }
     foreach ($improvedClassSource->getInterfaces() as $interface) {
         $initializable[] = $interface;
     }
     $lets = $improvedClassSource->getConstructorParameters();
     foreach ($improvedClassSource->getConstructorParameters() as $methodParameter) {
         if ($methodParameter->hasClass()) {
             $specSource->addImport($methodParameter->getClassType());
         }
     }
     //@TODO:
     foreach ($improvedClassSource->getMethods() as $method) {
         if ($method instanceof RepositoryConstructorMethod) {
             $lets[] = new Parameter('eventStore', InterfaceType::create('Broadway\\EventStore\\EventStoreInterface'));
             $lets[] = new Parameter('eventBus', InterfaceType::create('Broadway\\EventHandling\\EventBusInterface'));
             $lets[] = new Parameter('eventStreamDecorators', new ArrayType());
         }
     }
     $specSource->addMethod(new LetMethod($lets));
     $specSource->addMethod(new InitializableMethod($initializable));
     $skip = false;
     if (true === $improvedClassSource->hasParent()) {
         if ($improvedClassSource->getParent()->getFullName() === 'Broadway\\EventSourcing\\EventSourcingRepository') {
             $skip = true;
         }
     }
     if (false === $skip) {
         $specSource->addMethod(new ExposeConstructorArgumentsAsGettersMethod($lets));
     }
     return $specSource;
 }