コード例 #1
0
ファイル: Content.php プロジェクト: braseidon/ChillDevSpintax
 /**
  * Dumps source spintax format.
  *
  * @return string Merged content.
  * @version 0.0.1
  * @since 0.0.1
  */
 public function dump()
 {
     $content = $this->content;
     // dump all possible children paths
     if (!empty($this->children)) {
         $options = [];
         foreach ($this->children as $child) {
             $options[] = $child->dump();
         }
         $content .= '{' . implode('|', $options) . '}';
     }
     // continue further
     if (isset($this->next)) {
         $content .= $this->next->dump();
     }
     return $content;
 }
コード例 #2
0
 /**
  * @return Content
  * @version 0.0.1
  * @since 0.0.1
  */
 protected function buildTree()
 {
     $root = new Content('I ');
     $node = new Content('love ');
     $node->addChild(new Content('PHP'));
     $node->addChild(new Content('Java'));
     $node->addChild(new Content('C'));
     $node->addChild(new Content('C++'));
     $node->addChild(new Content('JavaScript'));
     $node->addChild(new Content('Python'));
     $root->addChild($node);
     $root->addChild(new Content('hate Ruby'));
     $root->setNext(new Content('.'));
     return $root;
 }