[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/lib/phpexcel/PHPExcel/Calculation/Token/ -> Stack.php (source)

   1  <?php
   2  
   3  /**
   4   * PHPExcel_Calculation_Token_Stack
   5   *
   6   * Copyright (c) 2006 - 2015 PHPExcel
   7   *
   8   * This library is free software; you can redistribute it and/or
   9   * modify it under the terms of the GNU Lesser General Public
  10   * License as published by the Free Software Foundation; either
  11   * version 2.1 of the License, or (at your option) any later version.
  12   *
  13   * This library is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16   * Lesser General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU Lesser General Public
  19   * License along with this library; if not, write to the Free Software
  20   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  21   *
  22   * @category   PHPExcel
  23   * @package    PHPExcel_Calculation
  24   * @copyright  Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel)
  25   * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt    LGPL
  26   * @version    ##VERSION##, ##DATE##
  27   */
  28  class PHPExcel_Calculation_Token_Stack
  29  {
  30      /**
  31       *  The parser stack for formulae
  32       *
  33       *  @var mixed[]
  34       */
  35      private $stack = array();
  36  
  37      /**
  38       *  Count of entries in the parser stack
  39       *
  40       *  @var integer
  41       */
  42      private $count = 0;
  43  
  44      /**
  45       * Return the number of entries on the stack
  46       *
  47       * @return  integer
  48       */
  49      public function count()
  50      {
  51          return $this->count;
  52      }
  53  
  54      /**
  55       * Push a new entry onto the stack
  56       *
  57       * @param  mixed  $type
  58       * @param  mixed  $value
  59       * @param  mixed  $reference
  60       */
  61      public function push($type, $value, $reference = null)
  62      {
  63          $this->stack[$this->count++] = array(
  64              'type'      => $type,
  65              'value'     => $value,
  66              'reference' => $reference
  67          );
  68          if ($type == 'Function') {
  69              $localeFunction = PHPExcel_Calculation::localeFunc($value);
  70              if ($localeFunction != $value) {
  71                  $this->stack[($this->count - 1)]['localeValue'] = $localeFunction;
  72              }
  73          }
  74      }
  75  
  76      /**
  77       * Pop the last entry from the stack
  78       *
  79       * @return  mixed
  80       */
  81      public function pop()
  82      {
  83          if ($this->count > 0) {
  84              return $this->stack[--$this->count];
  85          }
  86          return null;
  87      }
  88  
  89      /**
  90       * Return an entry from the stack without removing it
  91       *
  92       * @param   integer  $n  number indicating how far back in the stack we want to look
  93       * @return  mixed
  94       */
  95      public function last($n = 1)
  96      {
  97          if ($this->count - $n < 0) {
  98              return null;
  99          }
 100          return $this->stack[$this->count - $n];
 101      }
 102  
 103      /**
 104       * Clear the stack
 105       */
 106      public function clear()
 107      {
 108          $this->stack = array();
 109          $this->count = 0;
 110      }
 111  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1