00001 <?php 00035 class MatchGatekeeper implements MatchInterface 00036 { 00042 protected $objForbidenMatch; 00043 00049 protected $objAllowedMatch; 00050 00057 protected $objNotFoundValue = true; 00058 00063 protected $objDeniedValue = false; 00064 00068 public function __construct() 00069 { 00070 $this->objForbidenMatch = new MatchGroup(); 00071 $this->objAllowedMatch = new MatchGroup(); 00072 } 00073 00074 /* 00075 * set the forbiden list match 00076 * 00077 * @param Match $objForbidenMatch 00078 * @return MatchGatekeeper me 00079 */ 00080 public function setForbidenMatch( Match $objForbidenMatch ) 00081 { 00082 $this->objForbidenMatch = $objForbidenMatch; 00083 return $this; 00084 } 00085 00091 public function getForbiddenMatch() 00092 { 00093 return $this->objForbidenMatch; 00094 } 00095 00102 public function setAllowedMatch( Match $objAllowedMatch ) 00103 { 00104 $this->objAllowedMatch = $objAllowedMatch; 00105 return $this; 00106 } 00107 00113 public function getAllowedMatch() 00114 { 00115 return $this->objAllowedMatch; 00116 } 00117 00125 public function setNotFoundValue( $objValue ) 00126 { 00127 $this->objNotFoundValue = $objValue; 00128 $this->getAllowedMatch->setNotFoundValue( $objValue ); 00129 $this->getForbiddenMatch->setNotFoundValue( $objValue ); 00130 return $this; 00131 } 00132 00139 public function getNotFoundValue() 00140 { 00141 return $this->objNotFoundValue; 00142 } 00143 00150 public function setDeniedValue( $objValue ) 00151 { 00152 $this->objDeniedValue = $objValue; 00153 return $this; 00154 } 00155 00161 public function getDeniedValue() 00162 { 00163 return $this->objDeniedValue; 00164 } 00165 00172 public function match( $strName ) 00173 { 00174 // if forbidden list exists // 00175 if( $this->getForbiddenMatch()->isEmpty() == false ) 00176 { 00177 // if is forbidden // 00178 if( $this->getForbiddenMatch()->found( $strName ) ) 00179 { 00180 // return denied value // 00181 return $this->getDeniedValue(); 00182 } 00183 } 00184 // if allowed restriction list exists // 00185 if( $this->getAllowedMatch()->isEmpty() == false ) 00186 { 00187 // if is allowed // 00188 if( $this->getAllowedMatch()->found( $strName ) ) 00189 { 00190 // return the allowed value // 00191 return $this->getAllowedMatch()->match( $strName ); 00192 } 00193 else 00194 { 00195 // else return the denied value // 00196 return $this->getDeniedValue(); 00197 } 00198 } 00199 // else return the not found value // 00200 return $this->getNotFoundValue(); 00201 } 00202 00203 00210 public function found( $strName ) 00211 { 00212 // if forbidden list exists // 00213 if( $this->getForbiddenMatch()->isEmpty() == false ) 00214 { 00215 // if is forbidden // 00216 if( $this->getForbiddenMatch()->found( $strName ) ) 00217 { 00218 // return false // 00219 return false; 00220 } 00221 } 00222 // if allowed restriction list exists // 00223 if( $this->getAllowedMatch()->isEmpty() == false ) 00224 { 00225 // if is allowed // 00226 if( $this->getAllowedMatch()->found( $strName ) ) 00227 { 00228 // return true // 00229 return true; 00230 } 00231 } 00232 // the element was not founded in any list // 00233 return false; 00234 } 00235 00236 } 00237 ?>
1.5.9