PluginProbe
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More / 2.2.0
StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More v2.2.0
2.3.0 2.2.0 2.1.1 2.1.0 2.0.0 1.10.0 1.9.1 1.9.0 1.2.1 1.2.2 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6.0 All 59 releases
storeengine / includes / classes / eval-math / eval-math-stack.php

eval-math-stack.php in StoreEngine — Complete eCommerce Solution with Memberships, Licensing, Affiliates & More 2.2.0, at includes/classes/eval-math/eval-math-stack.php

65 lines 904 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace StoreEngine\Classes\EvalMath;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 /**
10 * Class EvalMathStack
11 *
12 * Expression-evaluator stack.
13 */
14 class EvalMathStack {
15
16 /**
17 * Stack array.
18 *
19 * @var array
20 */
21 public $stack = array();
22
23 /**
24 * Stack counter.
25 *
26 * @var integer
27 */
28 public $count = 0;
29
30 /**
31 * Push value into stack.
32 *
33 * @param mixed $val
34 */
35 public function push( $val ) {
36 $this->stack[ $this->count ] = $val;
37 $this->count++;
38 }
39
40 /**
41 * Pop value from stack.
42 *
43 * @return mixed
44 */
45 public function pop() {
46 if ( $this->count > 0 ) {
47 $this->count--;
48 return $this->stack[ $this->count ];
49 }
50 return null;
51 }
52
53 /**
54 * Get last value from stack.
55 *
56 * @param int $n
57 *
58 * @return mixed
59 */
60 public function last( $n = 1 ) {
61 $key = $this->count - $n;
62 return array_key_exists( $key, $this->stack ) ? $this->stack[ $key ] : null;
63 }
64 }
65