RomaricDrigon\MetaYaml\XsdGenerator::build PHP Метод

build() публичный Метод

main function
public build ( $schema_config, $indent = true )
    public function build($schema_config, $indent = true)
    {
        $this->schema_config = $schema_config;
        // we're gonna create XSD (XML) using a XmlWriter
        $writer = new \XMLWriter();
        $writer->openMemory();
        if ($indent) {
            $writer->setIndent(true);
            // will be easier to read
            $writer->setIndentString('    ');
            // soft tab, 4 spaces
        }
        $writer->startDocument('1.0', 'UTF-8');
        // build writer - use a reference, we don't want to recopy it each time
        $this->buildRootNode($schema_config['root'][$this->getFullName('type')], $schema_config['root'], $writer);
        $writer->endDocument();
        return $writer->outputMemory();
    }

Usage Example

Пример #1
0
 public function testWrongRootType()
 {
     $this->if($object = new testedClass())->and($config = array('root' => array('_type' => 'text')))->then->exception(function () use($object, $config) {
         $object->build($config);
     })->hasMessage("Only array root nodes are supported");
 }