Example #1
0
 public function testClear()
 {
     $this->list->insert('foo', new \stdClass(), 0);
     $this->list->insert('bar', new \stdClass(), 0);
     $this->assertEquals(2, count($this->list));
     $this->list->clear();
     $this->assertEquals(0, count($this->list));
     $this->assertSame(false, $this->list->current());
 }
 /**
  * Set key/value pairs to update
  *
  * @param  array $values Associative array of key values
  * @param  string $flag One of the VALUES_* constants
  * @throws Exception\InvalidArgumentException
  * @return Update
  */
 public function set(array $values, $flag = self::VALUES_SET)
 {
     if ($values === null) {
         throw new Exception\InvalidArgumentException('set() expects an array of values');
     }
     if ($flag == self::VALUES_SET) {
         $this->set->clear();
     }
     $priority = is_numeric($flag) ? $flag : 0;
     foreach ($values as $k => $v) {
         if (!is_string($k)) {
             throw new Exception\InvalidArgumentException('set() expects a string for the value key');
         }
         $this->set->insert($k, $v, $priority);
     }
     return $this;
 }