Sabberworm\CSS\CSSList\CSSList::removeDeclarationBlockBySelector PHP Method

removeDeclarationBlockBySelector() public method

Removes a declaration block from the CSS list if it matches all given selectors.
public removeDeclarationBlockBySelector ( array | string $mSelector, boolean $bRemoveAll = false )
$mSelector array | string The selectors to match.
$bRemoveAll boolean Whether to stop at the first declaration block found or remove all blocks
    public function removeDeclarationBlockBySelector($mSelector, $bRemoveAll = false)
    {
        if ($mSelector instanceof DeclarationBlock) {
            $mSelector = $mSelector->getSelectors();
        }
        if (!is_array($mSelector)) {
            $mSelector = explode(',', $mSelector);
        }
        foreach ($mSelector as $iKey => &$mSel) {
            if (!$mSel instanceof Selector) {
                $mSel = new Selector($mSel);
            }
        }
        foreach ($this->aContents as $iKey => $mItem) {
            if (!$mItem instanceof DeclarationBlock) {
                continue;
            }
            if ($mItem->getSelectors() == $mSelector) {
                unset($this->aContents[$iKey]);
                if (!$bRemoveAll) {
                    return;
                }
            }
        }
    }