Overview

Namespaces

  • BN
    • Collections
    • Compiler
      • Grammar
      • Parser
        • Operator
        • Token
      • Postfix
        • Operands
        • Operator
        • Token
      • Scanner
        • Converter
      • Token
  • Demo
  • None

Classes

  • PostfixEvaluator
  • ProcessToken
  • StackAccumulator
  • Variables

Interfaces

  • CalculatorErrorHandler
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace BN\Compiler\Postfix;
 4: 
 5: use BN\Compiler\Token\Token;
 6: 
 7: class Variables
 8: {
 9:     private $object;
10: 
11:     public function __construct()
12:     {
13:         $this->object = new \stdClass();
14:     }
15: 
16:     public function setVariables(\stdClass $object)
17:     {
18:         $this->object = $object;
19:     }
20: 
21:     public function exists(Token $token)
22:     {
23:         $variable = $this->tokenToVariableName($token);
24:         return property_exists($this->object, $variable);
25:     }
26: 
27:     public function get(Token $token)
28:     {
29:         $variable = $this->tokenToVariableName($token);
30:         return $this->object->$variable;
31:     }
32: 
33:     public function set(Token $token, $value)
34:     {
35:         $variable = $this->tokenToVariableName($token);
36:         $this->object->$variable = $value;
37:     }
38: 
39:     private function tokenToVariableName($token)
40:     {
41:         return substr($token->value, 1);
42:     }
43: }
44: 
BN-PHP - Big Number data type for PHP API documentation generated by ApiGen 2.8.0