Erebot  latest
A modular IRC bot for PHP 5.3+
Erebot\Event\Match\TextAbstract Class Reference

Abstract filter that matches events based on their content (text). More...

+ Inheritance diagram for Erebot\Event\Match\TextAbstract:

Public Member Functions

 __construct ($pattern, $requirePrefix=false)
 
 getPattern ()
 
 getPrefixRequirement ()
 
 match (\Erebot\Interfaces\Event\Base\Generic $event)
 
 setPattern ($pattern)
 
 setPrefixRequirement ($requirePrefix=false)
 

Protected Member Functions

 realMatch ($prefix, $text)
 

Protected Attributes

 $pattern
 Pattern used in comparisons, as a string.
 
 $requirePrefix
 Boolean or null indicating whether a prefix is required or not.
 

Detailed Description

Abstract filter that matches events based on their content (text).

Subclasses must provide the logic for the matching algorithm by overriding the _match() method.

Definition at line 30 of file TextAbstract.php.

Constructor & Destructor Documentation

Erebot\Event\Match\TextAbstract::__construct (   $pattern,
  $requirePrefix = false 
)

Creates a new instance of this filter.

Parameters
string$patternPattern to use in text comparisons.
bool | null$requirePrefix(optional) Whether a prefix will be required (true), allowed (null) or disallowed (false). The default is to prohibit the use of a prefix.
Exceptions
Erebot::InvalidValueExceptionThe given value for $pattern or $requirePrefix is invalid.

Definition at line 52 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\$pattern, Erebot\Event\Match\TextAbstract\$requirePrefix, Erebot\Event\Match\TextAbstract\setPattern(), and Erebot\Event\Match\TextAbstract\setPrefixRequirement().

Member Function Documentation

Erebot\Event\Match\TextAbstract::getPattern ( )

Returns the pattern associated with this filter.

Return values
stringPattern associated with this filter.

Definition at line 64 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\$pattern.

Erebot\Event\Match\TextAbstract::getPrefixRequirement ( )

Returns the prefix requirement constraint for this filter.

Return values
bool|nullEither true if a prefix is required, null if a prefix is allowed, false if a prefix is disallowed.

Definition at line 95 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\$requirePrefix.

Erebot\Event\Match\TextAbstract::match ( \Erebot\Interfaces\Event\Base\Generic  $event)

Decides whether the given event passes the filter or not.

Parameters
$eventAn event to try to match to the criterion expressed by this filter.
Return values
booltrue if the event matches the criterion, false otherwise.

Implements Erebot\Interfaces\Event\Match.

Definition at line 122 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\realMatch().

Erebot\Event\Match\TextAbstract::realMatch (   $prefix,
  $text 
)
abstractprotected

Actual method used to make the comparison against the incoming event. This method is passed the contents of the event and may use the values of the $_pattern and $_requirePrefix instance attributes to make the comparison.

Parameters
string$prefixCurrent prefix for commands, as defined in the configuration file.
string$textContent of the incoming event.
Return values
booltrue if the event's content passes the filter, false otherwise.

Referenced by Erebot\Event\Match\TextAbstract\match().

Erebot\Event\Match\TextAbstract::setPattern (   $pattern)

Sets the pattern associated with this filter.

Parameters
string$patternPattern to use in text comparisons.
Exceptions
Erebot::InvalidValueExceptionThe given value for $pattern is invalid.

Definition at line 78 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\$pattern, and Erebot\Utils\stringifiable().

Referenced by Erebot\Event\Match\TextAbstract\__construct().

Erebot\Event\Match\TextAbstract::setPrefixRequirement (   $requirePrefix = false)

Sets the constraint on prefix requirement.

Parameters
bool | null$requirePrefix(optional) Whether a prefix will be required (true), allowed (null) or disallowed (false). The default is to prohibit the use of a prefix.
Exceptions
Erebot::InvalidValueExceptionThe given value for $requirePrefix is invalid.

Definition at line 111 of file TextAbstract.php.

References Erebot\Event\Match\TextAbstract\$requirePrefix.

Referenced by Erebot\Event\Match\TextAbstract\__construct().


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