Source for file Rulecontextloaderstrategy.php

Documentation is available at Rulecontextloaderstrategy.php

  1. <?php   if defined('BASEPATH')) exit('No direct script access allowed');
  2. abstract class RuleContextLoaderStrategy {
  3.  
  4.     function RuleContextLoaderStrategy({
  5.     }
  6.     
  7.     abstract public function loadRuleContext$fileName$id );
  8.     
  9.     abstract protected function getRuleElementValue$tokens$args );
  10.     
  11.     abstract protected function processRuleContextStatement$tokens$args );
  12.     
  13.     public function loadRule$fileName {
  14.         $OPERATOR 1;
  15.         $STATEMENT 3;
  16.         $statements $this->getStatements$fileName );                
  17.         foreach$statements as $statement {
  18.             $tokens preg_split('/[\s,]+/'$statement );
  19.             $statementType count$tokens );
  20.             if $statementType == $OPERATOR {
  21.                 $this->processOperator$tokens$this->rule );
  22.             }
  23.             elseif $statementType == $STATEMENT {
  24.                 $this->processRuleStatement$tokens$this->rule );
  25.             }
  26.         }
  27.         return $this->rule;        
  28.     }
  29.     
  30.     protected function processRuleStatement$tokens$ruleOrRuleContext {
  31.         if$tokens== 'IS' {
  32.             $ruleOrRuleContext->addProposition$tokens](bool)$tokens);
  33.         }
  34.         elseif$tokens== 'EQUALS' {
  35.             $ruleOrRuleContext->addVariable$tokens]$tokens);
  36.         }
  37.     }
  38.  
  39.     protected function processOperator$tokens$ruleOrRuleContext {
  40.         $ruleOrRuleContext->addOperator$tokens);
  41.     }
  42.     
  43.     protected function getStatements$fileName {
  44.         $lines array();
  45.         $ruleFile fopen$fileName'r' );
  46.         if$ruleFile {
  47.             while!feof$ruleFile ) ) {
  48.                 $line trimfgets$ruleFile ) );
  49.                 if!empty$line and !$this->isCommentStatement$line ) ) {
  50.                     $lines[$line;
  51.                 }
  52.             }
  53.         }
  54.         else {
  55.             die'Failed to open stream: ' $fileName ' does not exist.' );
  56.         }
  57.         fclose$ruleFile );
  58.         return $lines;
  59.     }
  60.     
  61.     protected function isCommentStatement$text {
  62.         $text trim$text );
  63.         return strstr$text'#' == $text );
  64.     }    
  65. }
  66.  
  67. /* End of file Ruleloader.php */
  68. /* Location: ./system/application/libraries/Phprules/strategy/Rulecontextloaderstrategy.php */

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