Replace all children with an array of elements.

@param \Spatie\Html\HtmlElement[] $children
@param callable|null $mapper

@return static
333429
public function setChildren($children, $mapper = null)
    {
        $element = clone $this;

        $element->children = new Collection();

        return $element->addChildren($children, $mapper);
    }
8700
public function update($json, ChildrenOrderSaverMapperInterface $mapper)
    {
        $array = $this->parse($json);

        foreach ($array as $range => $value) {
            if (is_array($value)) {
                $mapper->save($value[RelationBuilder::TREE_PARAM_ID], $value[RelationBuilder::TREE_PARAM_PARENT_ID], $range);
            }
        }

        return true;
    }
975044
protected function renderList($class, array $children)
    {
        $ul = new NodeElement();
        $ul->openTag('ul')
           ->addAttribute('class', $class)
           ->finalize(true)
           ->appendChildren($children)
           ->closeTag();

        return $ul->render();
    }
1197854
public function setChildNodes(array $childNodes)
    {
        // Ensure integrity of $nodes array
        foreach ($childNodes as $childNode) {
            if (! is_a($childNode, AbstractNode::class)) {
                throw new \InvalidArgumentException(
                    'Error: Expected AbstractNode, but got "'.gettype($childNode).'"'
                );
            }
        }

        $this->childNodes = $childNodes;
    }
983258
protected function processMapper(CommandMapper $mapper) {
        $command = $mapper->getCommand();
        try {
            $mapper->delete();
            $command->execute();
        } catch (Exception $ex) {
            $this->erroneousMappers->push($mapper);
            Yii::getLogger()->log(
                    'An error ocurred while processing command [' . get_class($command) . '].'
                    . PHP_EOL
                    . 'Exception: [' . $ex->getTraceAsString() . ']', Logger::LEVEL_ERROR, 'command'
            );
        }
    }
897148
private static <K, V> HamtPMap<K, V>[] replaceChild(
      HamtPMap<K, V>[] children, int index, HamtPMap<K, V> child) {
    HamtPMap<K, V>[] newChildren = Arrays.copyOf(children, children.length);
    newChildren[index] = child;
    return newChildren;
  }
1253318
public function override_children(array $children) {
        $this->children = array();
        foreach ($children as $child) {
            if ($child instanceof custom_menu_item) {
                $this->children[] = $child;
            }
        }
    }
573371
function map(callable, children) {
  var iterator = (0, _cmap.default)(callable, children)[Symbol.asyncIterator]();
  return new _Children.default(iterator, undefined);
}
234242
public function addMaps(array $maps)
    {
        foreach ($maps as $locale => $map) {
            $this->addMap($locale, $map);
        }

        return $this;
    }
1323153
public function appendChildArray(array $children = null)
    {
        if (is_array($children) && !empty($children)) {
            foreach ($children as $child) {
                $this->appendChild($child);
            }
        }
    }
126478
public function map(callable $converter)
    {
        return new Enumerator(
            function () use($converter) {
                foreach ($this->each() as $k => $v) {
                    $v = call_user_func($converter, $v, $k);
                    yield $k => $v;
                }
            }
        );
    }
1166326
public function getChild(SegmentMatcher $matcher)
    {
        $hash = $matcher->getHash();

        return isset($this->children[$hash]) ? $this->children[$hash] : null;
    }
1324204
protected function getElementByTagInChildren(array $children, $tagName)
    {
        $elements = array();

        foreach ($children as $child) {
            if ($child instanceof BBcodeElementNode) {
                if ($tagName === $child->getTagName()) {
                    $elements[] = $child;
                }
                array_merge($elements, $this->getElementByTagInChildren($child->getChildren(), $tagName));
            }
        }

        return $elements;
    }
826232
public function setListMapper(ListMapper $mapper)
	{
		$this->listMapper = $mapper;
		$mapper->setAdmin($this);
		return $this;
	}
226733
public function data($mapper, $data)
    {
        // we won't deal with empty data
        if (is_array($data) && empty($data)
            || (($this->isPaginatorInstance($data)) && $data->isEmpty())
            || ($data instanceof Collection && $data->isEmpty())
        ) {
            return [];
        }
        // First we check whether we've been passed an array in which case we consider the array to be ['mapper',
        // 'method'] where 'mapper' can either be the mapper class name as a string or the actual instance.
        $method = 'map';
        if (is_array($mapper) && count($mapper) == 2) {
            $instance = $mapper[0];
            $method = $mapper[1];
            $mapper = $instance;
        }
        // check whether $mapper is an actual mapper instance, otherwise
        // resolve the mapper class name into a mapper instance.
        if (!is_object($mapper)) {
            $mapper = $this->resolveMapperClassName($mapper);
        }
        // In the case of a Collection or Paginator all we need is the data as a
        // Traversable so that we iterate and map each item.
        if ($data instanceof Collection) {
            $data = $data->all();
        } elseif ($this->isPaginatorInstance($data)) {
            $data = $data->items();
        }

        // call the map function of the mapper for each data in the $data array
        return (is_array($data) && !$this->isAssocArray($data)) ?
            array_map([$mapper, $method], $data) : $mapper->$method($data);
    }
422565
protected function mapMessagesToElementCollection(array $messages, ElementCollection $children)
    {
        $children->forAll(function (ElementInterface $element) use ($messages) {
            $this->mapMessagesToElement($messages, $element);
        });
    }
420591
protected function assignPrimaryKey(array & $mappers)
    {
        $foundPrimary = false;

        foreach ($mappers as $mapper) {
            if ($foundPrimary) {
                $mapper->field->isPrimary = false;
                $mapper->field->isAutoIncrement = false;
                continue;
            }

            if ($mapper->field->isPrimary()) {
                $mapper->field->isPrimary = true;
                $foundPrimary = true;
            }
        }

        return $this;
    }