public function __construct($item_list) { Kit::ensureArray($item_list); // @CAUTION $this->position = 0; $this->itemList = $item_list; }
private final function createEntityWithDocument($document) { // Kit::ensureDict($document); // @CAUTION Kit::ensureArray($document); if (FALSE === isset($document['_id']) or FALSE === $document['_id'] instanceof MongoId) { throw new UserException('_id is not set or proper in $document.', $document); } $document['_id'] = new MongoDBId($document['_id']); $entity_class_name = $this->entityClassName; return new $entity_class_name($this->collectionName, $this->entityPath, TRUE, $document); }
/** * Remove documents from this collection. * @param array $criterion Associative array with fields to match. * @param boolean $multiple If set to TRUE, all documents matching $criterion will be removed. * @return array Returns an array containing the status of the removal. * @throws MongoCursorException if the "w" option is set and the write fails. * @throws MongoCursorTimeoutException if the "w" option is set to a value greater than one * and the operation takes longer than MongoCursor::$timeout * milliseconds to complete. * This does not kill the operation on the server, * it is a client-side timeout. * The operation in MongoCollection::$wtimeout * is milliseconds. */ private final function mongoRemove($criterion, $multiple = TRUE) { $this->ensureInitialized(); // Kit::ensureDict($criterion); // @CAUTION Kit::ensureArray($criterion); Kit::ensureBoolean($multiple); $options = ['w' => 1, 'justOne' => FALSE === $multiple]; $status = $this->collection->remove($criterion, $options); self::$isChanged = TRUE; return $status; }
protected final function in($field_name, $field_value_list) { Kit::ensureString($field_name); Kit::ensureArray($field_value_list); // @CAUTION $criterion = [$field_name => ['$in' => $field_value_list]]; return $this->mergeCriterion($criterion); }
private final function setDocument($root_field_name, $field_name, $field_value, $ensure_dict = TRUE) { if (FALSE === Kit::in($root_field_name, self::$rootFieldNameList)) { throw new UserException('Invalid $root_field_name.', $root_field_name); } Kit::ensureString($field_name, TRUE); if ('' === $field_name) { throw new UserException('$field_name is a empty string.', [$root_field_name, $field_value]); } if (TRUE === is_null($field_name)) { if (TRUE === $ensure_dict) { // Kit::ensureDict($field_value); // @CAUTION Kit::ensureArray($field_value); // @CAUTION } return $this->set($root_field_name, $field_value); } else { $root_field_value = $this->get($root_field_name); $root_field_value[$field_name] = $field_value; return $this->set($root_field_name, $root_field_value); } }
/** * @param string $class_name * @param boolean $with_instantiate * @param array $arg_list * @return object */ private static final function createInstance($class_name, $with_instantiate, $arg_list) { Kit::ensureString($class_name); Kit::ensureBoolean($with_instantiate); Kit::ensureArray($arg_list); $reflection_class = new ReflectionClass($class_name); if (TRUE === $with_instantiate) { return $reflection_class->newInstanceArgs($arg_list); } else { return $reflection_class->newInstanceWithoutConstructor(); } }