Source for file Txtfileloaderstrategy.php

Documentation is available at Txtfileloaderstrategy.php

  1. <?php if defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3.  * Strategy pattern for loading a Rule from a text file.
  4.  * @author Greg Swindle <greg@swindle.net>
  5.  * @version 0.3
  6.  */
  7.  
  8.     public $rule;
  9.     public $ruleContext;
  10.  
  11.     public function TxtFileLoaderStrategy({
  12.         parent::RuleContextLoaderStrategy();
  13.     }    
  14.     
  15.     public function loadRuleContext$fileName$id {
  16.         $STATEMENT 3;
  17.         // $statements = $this->getStatements( $fileName );        
  18.         $statements $this->getStatements$fileName );
  19.         foreach$statements as $statement {
  20.             $tokens preg_split('/[\s,]+/'$statement );
  21.             // Every statement in the RuleContext file should have 
  22.             // four (4) tokens. If not, ignore it.
  23.             ifcount$tokens == $STATEMENT {
  24.                 $this->processRuleContextStatement$tokens$id );
  25.             }
  26.         }
  27.         return $this->ruleContext;
  28.     }
  29.     
  30.     protected function getRuleElementValue$tokens$args {
  31.         return $tokens];
  32.     }
  33.     
  34.     protected function processRuleContextStatement$tokens$args {
  35.         if$tokens== 'EQUALS' {
  36.             // It's a Variable
  37.             $this->ruleContext->addVariable$tokens]$tokens);
  38.         }
  39.         elseif$tokens== 'IS' {
  40.             // It's a Proposition
  41.             $this->ruleContext->addProposition$tokens]$tokens);
  42.         }
  43.     }
  44. }
  45. ?>

Documentation generated on Thu, 24 Mar 2011 21:27:43 -0500 by phpDocumentor 1.4.1