Changeset 119
Author: Thiago Mata
(2009/06/15 22:10) Over 2 years ago
rule match it is more mature. Next step it is make the code reflection use it. After that make the stereotypes rules.
Author: Thiago Mata
(2009/06/15 22:10) Over 2 years ago
rule match it is more mature. Next step it is make the code reflection use it. After that make the stereotypes rules.
print serialize( $objRule->validate( "else" ) ) ; // 1print serialize( $objRule->match( "else" ) ) ; // 1print serialize( $objRule->validate( "something" ) ) ; // 0print serialize( $objRule->match( "something" ) ) ; // 0print serialize( $objRule->validate( "else" ) ) ; // 0print serialize( $objRule->match( "else" ) ) ; // 0print serialize( $objRule->validate( "noop" ) ) ; // 1print serialize( $objRule->match( "noop" ) ) ; // 1{{$this->objNameRuleList->setNameList( $arrNameList );{{return $this->objNameRuleList->getNameList();{{{{{{* @var RuleNameMatchprotected $objIgnoredNameList = null;protected $objIgnoredRuleMatch = null;* @var RuleNameMatchprotected $objNameList = null;protected $objExclusiveRuleMatch = null;* Array with the string name values what should be not* be added into this match* If is empty, no one will be ignored* @var mixer** @var string[]protected $arrIgnoredNameList = array();protected $mixNotFoundValue = TRUE;/**public function __construct()* Array with the regular expressions of the values{* what should be not be added into this match$this->objIgnoredRuleMatch = new RuleMatch();*$this->objExclusiveRuleMatch = new ruleMatch();* If is empty, no one will be ignored}** @var string[]*/protected $arrIgnoredRegularExpressionList = array();/*** Array with the string name list of the exclusive* names what should be match* If is empty, anyone can enter.* @param RuleMatch $objIgnoredRuleMatch** @var string[]*/protected $arrExclusiveNameList = array();/*** Array with the string list name of the exclusive* regular expressions what should be match** If is empty, anyone can enter.** @var string[]*/protected $arrExclusiveRegularExpressionList = array();/*** Set the array with the ignored list name of the match** @see RuleMatchList->arrIgnoredNameList* @see RuleMatchList::getIgnoredNameList()* @param String[] $arrIgnoredNameListpublic function setIgnoredNameList( array $arrIgnoredNameList )public function setIgnoredRuleMatch( RuleMatch $objIgnoredRuleMatch ){{$this->arrIgnoredNameList = $arrIgnoredNameList;$this->objIgnoredRuleMatch = $objIgnoredRuleMatch;return $this;return $this;* get the array with the ignored list name of the match* @see RuleMatchList->arrIgnoredNameList* @return RuleMatch* @see RuleMatchList::setIgnoredNameList( String[] )* @return String[] $arrIgnoredNameListpublic function getIgnoredNameList()public function getIgnoredMatchList(){{return $this->arrIgnoredNameList;return $this->objIgnoredRuleMatch;* Add a string element name into the ignore list string* @see RuleMatchList->arrIgnoredNametString* @see RuleMatch::addName( string , mixer )* @see RuleMatchList::setIgnoredListString( String[] )* @see RuleMatchList::getIgnoredListString(){{$this->arrIgnoredNameList[] = $strIgnoredName;$this->getIgnoredMatchList()->addName( $strIgnoredName , TRUE );return $this;return $this;* Set the array with the exclusive name into the match* @see RuleMatchList->arrExclusiveNameList* @see RuleMatch::addRegularExpression( string , mixer )* @see RuleMatchList::getExclusiveNameList()* @param string $strIgnoreName* @param String[] $arrExclusiveNameListpublic function setExclusiveNameList( $arrExclusiveNameList )public function addIgnoredRegularExpression( $strIgnoredRegex){{$this->arrExclusiveNameList = $arrExclusiveNameList;$this->getIgnoredMatchList()->addRegularExpression( $strIgnoredRegex, TRUE );return $this;return $this;/*** get the array with the exclusive name into the match** @see RuleMatchList->arrExclusiveNameList* @see RuleMatchList::setExclusiveNameList( String[] )* @return String[] $arrExclusiveNameList*/public function getExclusiveNameList(){return $this->arrExclusiveNameList;}* Add a class name into the exclusive name list* @see RuleMatchList->arrExclusiveNameList* @param RuleMatch $objExclusiveRuleMatch* @see RuleMatchList::setExclusiveNameList( String[] )* @see RuleMatchList::getExclusiveClasses()* @param string $strExclusiveNamepublic function addExclusiveName( $strExclusiveName )public function setExclusiveRuleMatch( RuleMatch $objExclusiveRuleMatch ){{$this->arrExclusiveNameList[] = $strExclusiveName;$this->objExclusiveRuleMatch = $objExclusiveRuleMatch;return $this;return $this;* Set the array with the Ignored Regular Expression into the match* @see RuleMatchList->arrIgnoredRegularExpressionList* @return RuleMatch* @see RuleMatchList::getIgnoredRegularExpressionList()* @param String[] $arrIgnoredRegularExpressionList* @return RuleMatchList mepublic function setIgnoredRegularExpressionList( $arrIgnoredRegularExpressionList )public function getExclusiveMatchList(){{$this->arrIgnoredRegularExpressionList = $arrIgnoredRegularExpressionList;return $this->objExclusiveRuleMatch;return $this;* get the array with the Ignored Regular Expression into the match* add a exclusive name into the rule* @see RuleMatchList->arrIgnoredRegularExpressionList* @see RuleMatch::addName( string , mixer )* @see RuleMatchList::setIgnoredRegularExpressionList( String[] )* @param string $strExclusiveName* @return String[] $arrIgnoredRegularExpressionList* @param mixer $mixValue value of the element. Beware!*/public function getIgnoredRegularExpressionList(){return $this->arrIgnoredRegularExpressionList;}/*** Add a class Regular Expression into the Ignored Regular Expression list** @see RuleMatchList->arrIgnoredRegularExpressionList* @see RuleMatchList::setIgnoredRegularExpressionList( String[] )* @see RuleMatchList::getIgnoredClasses()* @param string $strIgnoredRegularExpressionpublic function addIgnoredRegularExpression( $strIgnoredRegularExpression )public function addExclusiveName( $strExclusiveName , $mixValue = TRUE ){{$this->arrIgnoredRegularExpressionList[] = $strIgnoredRegularExpression;$this->getExclusiveMatchList()->addName( $strExclusiveName , $mixValue);return $this;return $this;* Set the array with the exclusive Regular Expression into the match* @see RuleMatchList->arrExclusiveRegularExpressionList* @see RuleMatch::addRegularExpression( string , mixer )* @see RuleMatchList::getExclusiveRegularExpressionList()* @param string $strIgnoreName* @param String[] $arrExclusiveRegularExpressionListpublic function setExclusiveRegularExpressionList( $arrExclusiveRegularExpressionList )public function addExclusiveRegularExpression( $strExclusiveRegex ){{$this->arrExclusiveRegularExpressionList = $arrExclusiveRegularExpressionList;return $this;return $this;* get the array with the exclusive Regular Expression into the match* Set the value what should be return when the name* not be found into any list* @see RuleMatchList->arrExclusiveRegularExpressionList* @param mixer $mixValue* @see RuleMatchList::setExclusiveRegularExpressionList( String[] )* @return String[] $arrExclusiveRegularExpressionListpublic function getExclusiveRegularExpressionList()public function setNotFoundValue( $mixValue ){{return $this->arrExclusiveRegularExpressionList;$this->mixNotFoundValue = $mixValue;* Add a class Regular Expression into the exclusive Regular Expression list* Get the value what shoul be return when the name* not be found into any list* @see RuleMatchList->arrExclusiveRegularExpressionList* @return mixer* @see RuleMatchList::setExclusiveRegularExpressionList( String[] )* @see RuleMatchList::getExclusiveClasses()* @param string $strExclusiveRegularExpression* @return RuleMatchList mepublic function addExclusiveRegularExpression( $strExclusiveRegularExpression )public function getNotFoundValue(){{$this->arrExclusiveRegularExpressionList[] = $strExclusiveRegularExpression;return $this->mixNotFoundValue;return $this;* Validate the string name by the rules into the match and returns true* Match the string name* if should be considered and false if should not*** @return boolean* @return mixerpublic function validate( $strName , $strFullName = '' )public function match( $strName ){{// returns if it is into ignore listif( $this->getExclusiveMatchList()->isEmpty() == FALSE )if(( count( $this->getIgnoredNameList() ) > 0 )and(( in_array( $strName , $this->getIgnoredNameList() ) )||( in_array( $strFullName , $this->getIgnoredNameList() ) ))){{return false;return ( $this->getExclusiveMatchList()->match( $strName ) );else// returns if it is not into the exclusive listif(( count( $this->getExclusiveNameList() ) > 0 )and(( ! in_array( $strName , $this->getExclusiveNameList() ) )&&( ! in_array( $strFullName , $this->getExclusiveNameList() ) ))){{return false;if( $this->getIgnoredMatchList()->isEmpty() == FALSE )}// exists a ignore regular expression list //if( count( $this->getIgnoredRegularExpressionList() ) > 0 ){foreach( $this->getIgnoredRegularExpressionList() as $strRegex ){{if( ereg( $strRegex , $strMethod ) || ereg( $strRegex , $strFullName ) )if( $this->getIgnoredMatchList()->found( $strName ) ){{// and the method match into //return FALSE;return false;return $this->getNotFoundValue();// exists a exclusive methods regular expression list //if( count( $this->getExclusiveRegularExpressionList() ) > 0 ){foreach( $this->getExclusiveRegularExpressionList() as $strRegex ){if( ereg( $strRegex , $strName ) || ereg( $strRegex , $strFullName ) ){// and the element match into //return true;}}// and the element not match into //return false;}// not reasons was founded to ignore this element //return true;{* @param string $strRegularExpression* @param string $strNamepublic function found( $strRegularExpression )public function found( $strName ){{if ( in_array( $strRegularExpression , $this->arrRegularExpressionList ) )foreach( $this->arrRegularExpressionList as $intRegularExpressionKey => $strRegularExpression ){{return TRUE;if( ereg( $strRegularExpression , $strName ) ){return TRUE;}else{return FALSE;return FALSE;}{