@param array $items
@param string $idField

@throws \WebComplete\microDb\Exception
348822
public function insertBatch(array $items, string $idField = 'id')
    {
        $collectionData = $this->storage->load(true);
        if (!isset($collectionData['items'])) {
            $collectionData['items'] = [];
        }
        if (!isset($collectionData['inc'])) {
            $collectionData['inc'] = 1;
        }
        foreach ($items as &$item) {
            $item[$idField] = $collectionData['inc']++;
        }
        unset($item);
        $collectionData['items'] = \array_merge($collectionData['items'], $items);
        $this->storage->save($collectionData);
    }
1345187
protected function _resolveFields($fields)
    {
        if (is_string($fields)) {
            $fields = [$fields];
        }

        if (!is_array($fields)) {
            throw new Exception('Invalid "fields" configuration.');
        }

        $types = array_keys(Type::map());

        foreach ($fields as $field => $type) {
            if (is_numeric($field) && is_string($type)) {
                unset($fields[$field]);
                $field = $type;
                $type = self::DEFAULT_TYPE;
                $fields[$field] = $type;
            }

            if (!in_array($type, $types)) {
                throw new Exception(sprintf('The field "%s" mapped type "%s" was not found.', $field, $type));
            }
        }

        return $fields;
    }
202054
public function addItems( $items )
	{
		if( $items instanceof UI_HTML_Buffer ) 
			$this->addItem( $items->render() );
		else
			foreach( $items as $item )
				$this->addItem( $item );
	}
535840
public function foreverMany(array $items)
    {
        if (! method_exists($this->store, 'foreverMany')) {
            array_map([$this, 'forever'], array_keys($items), array_values($items));
        } else {
            $items = array_combine($this->tagKeys(array_keys($items)), array_values($items));

            $this->store->foreverMany($items);
        }
    }
499400
public static function arrayDiff($source,$subSource,$idField)
    {
        $keys=array();
        foreach($subSource as $item){
            $keys[]=Convert::getFieldValue($item, $idField,true);
        }

        $returnValue=[];
        foreach($source as $item){
            $key=Convert::getFieldValue($item, $idField,true);
            if(!in_array($key,$keys)){
                $returnValue[]=$item;
            }
        }
        return $returnValue;
    }
917561
public static <T> List<SelectableItem> listOf(
            Collection<T> items,
            Function<T, String> idFn,
            Function<T, String> nameFn,
            Predicate<T> selectedFn
    ) {
        return items.stream()
                .map(i ->
                        new SelectableItem(
                                selectedFn.test(i),
                                idFn.apply(i),
                                nameFn.apply(i)
                        )
                )
                .collect(Collectors.toList());
    }
152774
public function display_items( $items, $include_total = true, $order, $orderby ) {
		if ( 'table' === $this->args['format'] && empty( $this->args['field'] ) ) {
			$this->show_table( $order, $orderby, $items, $this->args['fields'], $include_total );
		} else {
			$this->formatter->display_items( $items );
		}
	}
948556
public function foreverMany(array $items)
    {
        if (! method_exists($this->store, 'foreverMany')) {
            array_map([$this, 'forever'], array_keys($items), array_values($items));
        } else {
            $this->store->foreverMany($items);

            foreach ($items as $key => $value) {
                $this->fireCacheEvent('write', [$key, $value, 0]);
            }
        }
    }
659016
public function dropDownList($items, $options = [], $generateDefault = true)
    {
        if ($generateDefault === true && !isset($options['prompt'])) {
            $options['prompt'] = Yii::t('yuncms', 'Please select');
        }
        return parent::dropDownList($items, $options);
    }
1099584
public void setFields(DBFField[] fields) {
		if (this.closed) {
			throw new IllegalStateException("You can not set fields to a closed DBFWriter");
		}
		if (this.header.fieldArray != null) {
			throw new DBFException("Fields has already been set");
		}
		if (fields == null || fields.length == 0) {
			throw new DBFException("Should have at least one field");
		}
		for (int i = 0; i < fields.length; i++) {
			if (fields[i] == null) {
				throw new DBFException("Field " + i + " is null");
			}
		}
		this.header.fieldArray = new DBFField[fields.length];
		for (int i = 0; i < fields.length; i++) {
			this.header.fieldArray[i] = new DBFField(fields[i]);
		}
		try {
			if (this.raf != null && this.raf.length() == 0) {
				// this is a new/non-existent file. So write header before proceeding
				this.header.write(this.raf);
			}
		} catch (IOException e) {
			throw new DBFException("Error accesing file:" + e.getMessage(), e);
		}
	}
698635
public function select($name = null, $value = null, array $items = array()) 
	{
		Argument::i()
			->test(1, 'string', 'null')
			->test(2, 'scalar', 'null');
			
		$field = Select::i()->setItems($items);
		
		if(!is_null($name)) {
			$field->setName($name);
		}
		
		if(!is_null($value)) {
			$field->setValue($value);
		}
		
		return $field;
	}
464256
public static <T> void addScalarArray(JSONWriter writer, String field,
			Collection<T> items, JsonObjectWriter<T> objWriter)
			throws JSONException {
		writer.key(field);
		writer.array();
		for (T item : items) {
			objWriter.write(writer, item);
		}
		writer.endArray();
	}
1015825
public function setFields(array $fields)
    {
        foreach ($fields as $field => $value) {
            if (property_exists($this, $field)) {
                $this->{$field} = $value;
            }
        }

        if (isset($fields['_embedded'])) {
            foreach ($fields['_embedded'] as $embeddedType => $embeddedValue) {
                if (property_exists($this, $embeddedType)) {
                    $propertyObject = $this->factory->createFromPropertyName($embeddedType);
                    if ($propertyObject === null) {
                        continue;
                    }

                    if (is_array($propertyObject)) { //Property is a collection
                        foreach ($embeddedValue as $entityType => $entityFields) {
                            $entityObject = $this->factory->createFromPropertyName($entityType);
                            if ($entityObject === null) {
                                continue;
                            }

                            $entityObject->setFields($entityFields);

                            $propertyObject[] = $entityObject;
                        }
                    } else { //Property is an entity
                        $propertyObject->setFields($embeddedValue);
                    }

                    $this->{$embeddedType} = $propertyObject;
                }
            }
        }
    }
1258251
public function add($items = [])
    {
        if (!is_array($items) || func_num_args() > 1) {
            $items = func_get_args();
        }

        $this->push($this->formatInnerField(null, $items));
    }
1087692
public function process(Collection $items, Closure $cb, Closure $error = null): void
    {
        $items->each(function ($item) use ($cb, $error): void {
            try {
                $cb($item);
            } catch (Exception $e) {
                if (! $error) {
                    throw $e;
                }

                $error($e);
            }
        });
    }
257832
public static <T> void addArrayIfNotNull(JSONWriter writer, String field,
			Collection<T> items, JsonObjectWriter<T> objWriter)
			throws JSONException {
		if (items == null)
			return;
		addCollection(writer, field, items, objWriter);
	}
774744
public function setDefaultNull($fieldNames)
    {
        if (is_array($fieldNames))
        {
            foreach ($fieldNames as $field_name)
            {
                $this->setDefaultNull($field_name);
            }
        }
        else
        {
            if (isset($this->m_fields[$fieldNames]))
            {
                $this->m_fields[$fieldNames]->setDefault('NULL');
            }
            else
            {
                $err_msg = '[' . $fieldNames . '] field not found in table ' .
                           '[' . $this->m_name . '] when setting null fields';

                throw new \Exception($err_msg);
            }
        }
    }