Skip to content

Commit 3780f73

Browse files
authored
Merge pull request MyIntervals#152 from xwp/add/splice-method
Add splice method to CSSList
2 parents 2d2545a + a7a80b4 commit 3780f73

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

lib/Sabberworm/CSS/CSSList/CSSList.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,17 +176,39 @@ public function getLineNo() {
176176
return $this->iLineNo;
177177
}
178178

179+
/**
180+
* Prepend item to list of contents.
181+
*
182+
* @param object $oItem Item.
183+
*/
179184
public function prepend($oItem) {
180185
array_unshift($this->aContents, $oItem);
181186
}
182187

188+
/**
189+
* Append item to list of contents.
190+
*
191+
* @param object $oItem Item.
192+
*/
183193
public function append($oItem) {
184194
$this->aContents[] = $oItem;
185195
}
186196

197+
/**
198+
* Splice the list of contents.
199+
*
200+
* @param int $iOffset Offset.
201+
* @param int $iLength Length. Optional.
202+
* @param RuleSet[] $mReplacement Replacement. Optional.
203+
*/
204+
public function splice($iOffset, $iLength = null, $mReplacement = null) {
205+
array_splice($this->aContents, $iOffset, $iLength, $mReplacement);
206+
}
207+
187208
/**
188209
* Removes an item from the CSS list.
189210
* @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)
211+
* @return bool Whether the item was removed.
190212
*/
191213
public function remove($oItemToRemove) {
192214
$iKey = array_search($oItemToRemove, $this->aContents, true);

0 commit comments

Comments
 (0)