MatchGatekeeper Class Reference

Inheritance diagram for MatchGatekeeper:

MatchInterface

List of all members.

Public Member Functions

 __construct ()
 setForbidenMatch (Match $objForbidenMatch)
 getForbiddenMatch ()
 setAllowedMatch (Match $objAllowedMatch)
 getAllowedMatch ()
 setNotFoundValue ($objValue)
 getNotFoundValue ()
 setDeniedValue ($objValue)
 getDeniedValue ()
 match ($strName)
 found ($strName)

Protected Attributes

 $objForbidenMatch
 $objAllowedMatch
 $objNotFoundValue = true
 $objDeniedValue = false


Detailed Description

Thiago Henrique Ramos da Mata <thiago.henrique.mata@gmail.com>
Since:
2009-06-12
Gate opener make a match using white list , with the allowed names and black list, with the forbiden names.

Example:
   $objMatch = new MatchGatekeeper();
   $objMatch->getAllowedMatch()->addItemName( "just" );
   $objMatch->getAllowedMatch()->addItemName( "us" );
         if ( $objMatch->match( "other" ) !== false ) return false;
   return true;
returns
 true 
Example:
   $objMatch = new MatchGatekeeper();
   $objMatch->getForbiddenMatch()->addItemRegularExpression( "^set*" );
   $objMatch->getForbiddenMatch()->addItemRegularExpression( "^get*" );
   $objMatch->getForbiddenMatch()->addItemName( "play" );
         if ( $objMatch->match( "setSomething" ) !== false ) return false;
         if ( $objMatch->match( "getSomething" ) !== false ) return false;
         if ( $objMatch->match( "play" ) !== false ) return false;
         if ( $objMatch->match( "other" ) !== true) return false;
   return true;
returns
 true 

Definition at line 35 of file MatchGatekeeper.class.php.


Constructor & Destructor Documentation

__construct (  ) 

constructor create the class matchs

Definition at line 68 of file MatchGatekeeper.class.php.

00069     {
00070         $this->objForbidenMatch = new MatchGroup();
00071         $this->objAllowedMatch = new MatchGroup();
00072     }


Member Function Documentation

found ( strName  ) 

Found the string name

Parameters:
string $strName
Returns:
object <value>

Implements MatchInterface.

Definition at line 210 of file MatchGatekeeper.class.php.

References getAllowedMatch(), and getForbiddenMatch().

Referenced by match().

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     }

getAllowedMatch (  ) 

Get the allowed list match

Returns:
MatchGroup

Definition at line 113 of file MatchGatekeeper.class.php.

Referenced by found(), match(), and setNotFoundValue().

00114     {
00115         return $this->objAllowedMatch;
00116     }

getDeniedValue (  ) 

Get the value of a name into the forbidden list

Returns:
object <value>

Definition at line 161 of file MatchGatekeeper.class.php.

Referenced by match().

00162     {
00163         return $this->objDeniedValue;
00164     }

getForbiddenMatch (  ) 

get the forbiden list match

Returns:
MatchGroup

Definition at line 91 of file MatchGatekeeper.class.php.

Referenced by found(), match(), and setNotFoundValue().

00092     {
00093         return $this->objForbidenMatch;
00094     }

getNotFoundValue (  ) 

Get the value what shoul be return when the name not be found into any list

Returns:
object <value>

Implements MatchInterface.

Definition at line 139 of file MatchGatekeeper.class.php.

Referenced by match().

00140     {
00141         return $this->objNotFoundValue;
00142     }

match ( strName  ) 

Match the string name

Parameters:
string $strName
Returns:
object <value>

Implements MatchInterface.

Definition at line 172 of file MatchGatekeeper.class.php.

References found(), getAllowedMatch(), getDeniedValue(), getForbiddenMatch(), and getNotFoundValue().

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     }

setAllowedMatch ( Match $  objAllowedMatch  ) 

Set the allowed list match

Parameters:
Match $objAllowedMatch
Returns:
MatchGatekeeper me

Definition at line 102 of file MatchGatekeeper.class.php.

00103     {
00104         $this->objAllowedMatch = $objAllowedMatch;
00105         return $this;
00106     }

setDeniedValue ( objValue  ) 

Set the value of a name into the forbidden list

Parameters:
object $objValue
Returns:
MatchGatekeeper

Definition at line 150 of file MatchGatekeeper.class.php.

00151     {
00152         $this->objDeniedValue = $objValue;
00153         return $this;
00154     }

setForbidenMatch ( Match $  objForbidenMatch  ) 

Definition at line 80 of file MatchGatekeeper.class.php.

00081     {
00082         $this->objForbidenMatch = $objForbidenMatch;
00083         return $this;
00084     }

setNotFoundValue ( objValue  ) 

Set the value what should be return when the name not be found into any list

Parameters:
object $objValue
Returns:
MatchGatekeeper

Implements MatchInterface.

Definition at line 125 of file MatchGatekeeper.class.php.

References getAllowedMatch(), and getForbiddenMatch().

00126     {
00127         $this->objNotFoundValue = $objValue;
00128         $this->getAllowedMatch->setNotFoundValue( $objValue );
00129         $this->getForbiddenMatch->setNotFoundValue( $objValue );
00130         return $this;
00131     }


Member Data Documentation

$objAllowedMatch [protected]

Match Group of the Allowed List

MatchGroup

Definition at line 49 of file MatchGatekeeper.class.php.

$objDeniedValue = false [protected]

Value what should return when the name match into the forbiden list

Definition at line 63 of file MatchGatekeeper.class.php.

$objForbidenMatch [protected]

Match Group of the Forbidden List

MatchGroup

Definition at line 42 of file MatchGatekeeper.class.php.

$objNotFoundValue = true [protected]

Value what should return when the name dont match with the allowed list even with the forbiden list

object

Definition at line 57 of file MatchGatekeeper.class.php.


The documentation for this class was generated from the following file:

Generated on Thu Feb 3 03:55:03 2011 for CodeToDiagram by  doxygen 1.5.9