From a7a80b4e28c8feebeff95413e2b41ef8487cfb65 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 14 Jan 2019 13:47:27 -0800 Subject: [PATCH] Add splice method to CSSList --- lib/Sabberworm/CSS/CSSList/CSSList.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/Sabberworm/CSS/CSSList/CSSList.php b/lib/Sabberworm/CSS/CSSList/CSSList.php index c4b28065..3736d8f3 100644 --- a/lib/Sabberworm/CSS/CSSList/CSSList.php +++ b/lib/Sabberworm/CSS/CSSList/CSSList.php @@ -176,17 +176,39 @@ public function getLineNo() { return $this->iLineNo; } + /** + * Prepend item to list of contents. + * + * @param object $oItem Item. + */ public function prepend($oItem) { array_unshift($this->aContents, $oItem); } + /** + * Append item to list of contents. + * + * @param object $oItem Item. + */ public function append($oItem) { $this->aContents[] = $oItem; } + /** + * Splice the list of contents. + * + * @param int $iOffset Offset. + * @param int $iLength Length. Optional. + * @param RuleSet[] $mReplacement Replacement. Optional. + */ + public function splice($iOffset, $iLength = null, $mReplacement = null) { + array_splice($this->aContents, $iOffset, $iLength, $mReplacement); + } + /** * Removes an item from the CSS list. * @param RuleSet|Import|Charset|CSSList $oItemToRemove May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset or another CSSList (most likely a MediaQuery) + * @return bool Whether the item was removed. */ public function remove($oItemToRemove) { $iKey = array_search($oItemToRemove, $this->aContents, true);