Beispiel #1
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return CharClass
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     if (!$child->canBeAddedToCharClassRange()) {
         throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " cannot be added to character class ranges");
     } elseif (count($this->getChildren()) === 2) {
         throw new \REBuilder\Exception\Generic("Character class ranges can contain only 2 children");
     }
     return parent::addChildAt($child, $index);
 }
Beispiel #2
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return AbstractContainer
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     $child->setParent($this);
     if ($index === null) {
         $this->_children[] = $child;
     } elseif (isset($this->_children[$index])) {
         array_splice($this->_children, $index, 0, array($child));
     } else {
         $this->_children[$index] = $child;
         ksort($this->_children);
     }
     return $this;
 }
Beispiel #3
0
 /**
  * Adds a child to the class at the given index
  * 
  * @param AbstractPattern $child Child to add
  * @param int             $index Index
  * 
  * @return CharClass
  * 
  * @throws \REBuilder\Exception\Generic
  */
 public function addChildAt(AbstractPattern $child, $index = null)
 {
     if (!$child->canBeAddedToCharClass()) {
         throw new \REBuilder\Exception\Generic($this->_getClassName($child) . " cannot be added to character classes");
     }
     return parent::addChildAt($child, $index);
 }