Skip to content

Commit 26fec23

Browse files
author
Frederic Massart
committed
REMOVE ME ONCE MyIntervals/PHP-CSS-Parser#115 is merged
1 parent f593f69 commit 26fec23

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/php-css-parser/CSSList/CSSList.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ public function append($oItem) {
3535
$this->aContents[] = $oItem;
3636
}
3737

38+
/**
39+
* Insert an item before its sibling.
40+
*
41+
* @param mixed $oItem The item.
42+
* @param mixed $oSibling The sibling.
43+
*/
44+
public function insert($oItem, $oSibling) {
45+
$iIndex = array_search($oSibling, $this->aContents);
46+
if ($iIndex === false) {
47+
return $this->append($oItem);
48+
}
49+
array_splice($this->aContents, $iIndex, 0, array($oItem));
50+
}
51+
3852
/**
3953
* Removes an item from the CSS list.
4054
* @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)

0 commit comments

Comments
 (0)