3 namespace RemexHtml\TreeBuilder;
6 * The stack of template insertion modes. We use a storage model optimised for
7 * access to the element at the top of the stack, which is stored separately
8 * from the rest of the stack.
10 class TemplateModeStack {
12 * The insertion mode at the top of the stack. This is public for
13 * performance reasons but should be treated as read-only.
19 * The remainder of the stack
21 private $nonCurrentModes = [];
24 * Push a mode on to the stack
25 * @param integer $mode
27 public function push( $mode ) {
28 $this->nonCurrentModes[] = $this->current;
29 $this->current = $mode;
33 * Pop a mode from the stack
35 public function pop() {
36 $this->current = array_pop( $this->nonCurrentModes );
40 * Return true if the stack is empty, false otherwise
43 public function isEmpty() {
44 return $this->current === null;