public function testCountable() { $doc = new Epic_Mongo_Document(); $doc->setProperty('key', 'value'); $this->assertEquals(1, count($doc)); $doc->setProperty('key2', 'value2'); $this->assertEquals(2, count($doc)); }
public function setProperty($key, $value) { $new = is_null($key); if (!$new && !is_numeric($key)) { throw new Epic_Mongo_Exception('DocumentSets must only contain numeric keys'); } if (!(is_null($value) || $value instanceof Epic_Mongo_Document)) { throw new Epic_Mongo_Exception('DocumentSets must only contain documents'); } if ($new) { $keys = $this->getPropertyKeys(); if (empty($keys)) { $key = 0; } else { $key = max($keys) + 1; } } return parent::setProperty($key, $value); }