Phpro\SoapClient\CodeGenerator\TypeGenerator::generate PHP Method

generate() public method

public generate ( Zend\Code\Generator\FileGenerator $file, Type $type ) : string
$file Zend\Code\Generator\FileGenerator
$type Phpro\SoapClient\CodeGenerator\Model\Type
return string
    public function generate(FileGenerator $file, $type)
    {
        $class = $file->getClass() ?: new ClassGenerator();
        $class->setNamespaceName($type->getNamespace());
        $class->setName($type->getName());
        $this->ruleSet->applyRules(new TypeContext($class, $type));
        foreach ($type->getProperties() as $property) {
            $this->ruleSet->applyRules(new PropertyContext($class, $type, $property));
        }
        $file->setClass($class);
        return $file->generate();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Generates one type class
  *
  * @param FileGenerator $file
  * @param TypeGenerator $generator
  * @param Type          $type
  * @param string        $path
  */
 protected function generateType(FileGenerator $file, TypeGenerator $generator, Type $type, $path)
 {
     $code = $generator->generate($file, $type);
     $this->filesystem->putFileContents($path, $code);
 }