Пример #1
0
 /**
  * @covers Element::un_set
  */
 public function testUn_set()
 {
     $key = "src";
     $value = "img/logo.pgn";
     $result = $this->elt->set($key, $value);
     $this->assertSame($value, $result->get($key));
     $result->un_set($key);
     $this->assertNull($result->get($key));
 }
Пример #2
0
 public function valid()
 {
     if ($this->_position == 0 && !isset($this->_item->elements[$this->identifier], $this->_item->elements[$this->identifier][0])) {
         parent::set(0, array());
     }
     return parent::get($this->_position) !== null;
 }
Пример #3
0
 /**
  * Overridden to handle key=class.
  * 
  * (non-PHPdoc)
  * @see classes/core/Element#set($key, $val)
  */
 public function set($key, $val = null)
 {
     if (strtolower($key) == 'class') {
         return $this->setClass($val);
     }
     // In all other cases
     return parent::set($key, $val);
 }
Пример #4
0
 /**
  * Set value to the given key.
  * If $addToArray is true, existing keys will not be overwritten, rather,
  * if the new value is already in the map, it will be added into an array.
  *
  * @param String $key
  * @param String $val
  * @param Boolean $addToArray
  * @return Href
  */
 public function set($key, $val = null, $addToArray = false)
 {
     // Serialize value if it's an object
     if (is_object($val)) {
         $val = $val->__toString();
     }
     // Support 'addToArray', if new value is not an array.
     if ($addToArray && !is_array($val)) {
         $existingVal = $this->get($key);
         // If there is an existing value
         if ($existingVal !== null) {
             // Turn existing value into an array (if it's not already)
             if (!is_array($existingVal)) {
                 $existingVal = array($existingVal);
             }
             // Add new value to array
             $existingVal[] = $val;
             // Set the array into '$val' and proceed normally
             $val = $existingVal;
         }
     }
     return parent::set($key, $val);
 }