Collapse selectors

@param array $selectors

@return string
501925
protected function collapseSelectors($selectors)
    {
        $parts = [];

        foreach ($selectors as $selector) {
            $output = '';

            array_walk_recursive(
                $selector,
                function ($value, $key) use (&$output) {
                    $output .= $value;
                }
            );

            $parts[] = $output;
        }

        return implode(', ', $parts);
    }
691488
public static function collapseSerialized(EloquentCollection $collection)
	{
		return $collection->map(
			function (SerializedModel $menu_item) {
				return $menu_item->serialized();
			}
		)->collapse();
	}
450240
public function collapsed()
    {
        $collapsed = $this->collapsible();

        if (is_bool($this->collapsed)) {
            $collapsed = $this->collapsed;
        }

        if (is_bool($this->isSelected())) {
            $collapsed = !$this->isSelected;
        }

        return $collapsed;
    }
273901
private function getCssSelectorPrecedence($selector)
    {
        $selectorKey = md5($selector);
        if (!isset($this->caches[self::CACHE_KEY_SELECTOR][$selectorKey])) {
            $precedence = 0;
            $value = 100;
            // ids: worth 100, classes: worth 10, elements: worth 1
            $search = ['\\#', '\\.', ''];

            foreach ($search as $s) {
                if (trim($selector) === '') {
                    break;
                }
                $number = 0;
                $selector = preg_replace('/' . $s . '\\w+/', '', $selector, -1, $number);
                $precedence += ($value * $number);
                $value /= 10;
            }
            $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey] = $precedence;
        }

        return $this->caches[self::CACHE_KEY_SELECTOR][$selectorKey];
    }
349594
function findAndRemove($selector, $idx = null ,$excludes = array())
    {
        if (empty($excludes)) return $this->find($selector,$idx);

        foreach ($excludes as $exclude) {
            foreach ($this->find($exclude) as $node) {
                $node->outertext = '';
            }
        }
        $this->load($this->save());
        return $this->find($selector,$idx);
    }
827675
public function siblings($selector=null)
    {
        $result = $this->createChildInstance();

        if (isset($this->document) && $this->length > 0) {
            foreach ($this->nodes as $node) {
                if ($node->parentNode) {
                    foreach ($node->parentNode->childNodes as $sibling) {
                        if ($sibling instanceof \DOMElement && !$sibling->isSameNode($node)) {
                            $result->addDomNode($sibling);
                        }
                    }
                }
            }

            if ($selector) {
                $result = $result->filter($selector);
            }
        }

        return $result;
    }
59834
public function collapse()
        {
            $results = array();

            foreach ($this->_items as $values) {
                $results = array_merge($results, $values);
            }

            return new static($results);
        }
1206234
public function collapse()
    {
        $results = array();

        foreach ($this->items as $values) {
            $results = array_merge($results, $values);
        }

        return new static($results);
    }
597183
private function selectFirst($links, $selector)
    {
        $result = array();
        $formats = preg_split('/\s*,\s*/', $selector);

        // has to be in this order
        foreach ($formats as $f) {

            foreach ($links as $l) {

                if (stripos($l['format'], $f) !== false || $f == 'any') {
                    $result[] = $l;
                }
            }
        }

        return $result;
    }
1172716
public function flatten(array $elements)
    {
        $level = [];

        foreach ($elements as $node)
        {
            if (is_array($node))
            {
                $level = array_merge($level, $this->flatten($node));
            }
            else
            {
                $level[] = $node;
            }
        }

        return $level;
    }
274264
protected function indentArray(array $elements) {
		return self::INDENTATION . \str_replace(PHP_EOL, PHP_EOL . self::INDENTATION, \implode(PHP_EOL, $elements));
	}
830592
public function querySelector(string $selectors): ?\DOMElement
    {
        $crawler = $this->getCrawler();

        $filteredCrawler = $crawler->filter($selectors);

        if (0 === $filteredCrawler->count()) {
            return null;
        }

        return $filteredCrawler->getNode(0);
    }
329766
protected function makeOutputBlock($type, $selectors = null)
    {
        $b = new stdclass();
        $b->lines = array();
        $b->children = array();
        $b->selectors = $selectors;
        $b->type = $type;
        $b->parent = $this->scope;

        return $b;
    }
731723
static public function implodeStyles(array $styles)
    {
        $a = [];

        foreach ($styles as $p => $v) {
            $a[] = "$p:$v";
        }

        return implode(';', $a);
    }
256229
public static function getBySelector($array, $selector)
    {
        if (strpos($selector, '[*]') === false) {
            return array(
                $selector => self::getByPath($array, $selector)
            );
        }
        $result = array();
        list($preffix, $suffix) = explode('[*]', $selector, 2);

        $base = self::getByPath($array, $preffix);
        if (! is_array($base)) {
            $base = array();
        }
        // we don't have a suffix, the selector was something like path[subpath][*]
        if (! $suffix) {
            foreach ($base as $k => $v) {
                $result["{$preffix}[{$k}]"] = $v;
            }
            // we have a suffix, the selector was something like path[*][item]
        } else {
            foreach ($base as $itemKey => $itemValue) {
                if (is_array($itemValue)) {
                    $result["{$preffix}[{$itemKey}]{$suffix}"] = self::getByPath($itemValue, $suffix);
                }
            }
        }

        return $result;
    }
1353034
public static function recursiveMerge(...$arrays)
    {
        $merged = array ();
        foreach($arrays as $array)
        {
            if (!is_array($array))
            {
                continue;
            }
            foreach ( $array as $key => $value )
            {
                if (is_string ( $key ))
                {
                    if (is_array ( $value ) && isset($merged[$key]) && is_array ( $merged [$key] ))
                    {
                        $merged [$key] = static::recursiveMerge ( $merged [$key], $value );
                    }
                    else
                    {
                        $merged [$key] = $value;
                    }
                }
                else
                {
                    $merged [] = $value;
                }
            }
        }
        return $merged;
    }
1167018
def collapse_indents(indentation):
    """"""
    change_in_level = ind_change(indentation)
    if change_in_level == 0:
        indents = ""
    elif change_in_level < 0:
        indents = closeindent * (-change_in_level)
    else:
        indents = openindent * change_in_level
    return indentation.replace(openindent, "").replace(closeindent, "") + indents