Ejemplo n.º 1
0
 public function generate(ImprovedClassSource $classSource)
 {
     //Building class.
     $classCode = $this->builderFactory->class($classSource->getName());
     //Add parent to class.
     if ($classSource->hasParent()) {
         $classCode->extend($classSource->getParentName());
     }
     //Add interfaces
     foreach ($classSource->getInterfaces() as $interface) {
         $classCode->implement($interface->getName());
     }
     //Add traits
     foreach ($classSource->getTraits() as $trait) {
         $classCode->addStmt($this->createTrait($trait));
     }
     foreach ($classSource->getProperties() as $property) {
         $classCode->addStmt($this->createClassProperty($property));
     }
     return $classCode;
 }
 public function let(ImprovedClassSource $classSource)
 {
     $classSource->getName()->willReturn('SomeClass');
     $classSource->getProperties()->willReturn([]);
     $this->beConstructedWith($classSource);
 }