public function generate(ConstructorMethod $method)
 {
     $constructor = $this->builderFactory->method('__construct')->makePublic();
     foreach ($method->getMethodParameters() as $param) {
         $constructor->addParam($this->createMethodParam($param));
         $constructor->addStmt($this->createConstructorMethodAssignment($param));
     }
     return $constructor;
 }
 public function it_will_not_show_plain_params_from_constructor_in_imports(ConstructorMethod $constructor, Parameter $param)
 {
     $constructor->getMethodParameters()->willReturn([$param]);
     $param->hasClass()->willReturn(false);
     $this->addConstructorMethod($constructor)->shouldReturn($this);
     $this->getImports()->shouldReturn([]);
 }
 public function addConstructorMethod(ConstructorMethod $constructor)
 {
     if ($this->hasConstructorMethod()) {
         throw new \Exception('Err 1000200: Class already has constructor!');
     }
     $this->constructor = $constructor;
     foreach ($constructor->getMethodParameters() as $parameter) {
         if ($parameter->hasClass()) {
             $this->addImportIfEligible($parameter->getClassType());
         }
         $this->addProperty($parameter);
     }
     $this->addMethod($constructor);
     foreach ($constructor->getMethodParameters() as $parameter) {
         $this->addGetterMethod($parameter);
     }
     return $this;
 }