PHP Class Phergie_Plugin_Karma, phergie

Inheritance: extends Phergie_Plugin_Abstract
Mostra file Open project: phergie/phergie

Protected Properties

Property Type Description
$db resource SQLite object
$fetchFixedKarma PDOStatement Retrieves an existing fixed karma record
$fetchKarma PDOStatement Retrieves an existing karma record
$fetchNegativeAnswer PDOStatement Retrieves a negative answer for a karma comparison
$fetchPositiveAnswer PDOStatement Retrieves a positive answer for a karma comparison
$insertKarma PDOStatement Prepared statement to add a new karma record
$updateKarma PDOStatement Prepared statement to update an existing karma record

Public Methods

Method Description
getDb ( ) : PDO Returns a connection to the plugin database, initializing one if none is explicitly set.
onCommandKarma ( string $term ) : void Get the karma rating for a given term.
onCommandReincarnate ( string $term ) : void Resets the karma for a term to 0.
onLoad ( ) : void Check for dependencies and initializes a database connection and prepared statements.
onPrivmsg ( ) : void Intercepts a message and processes any contained recognized commands.
setDb ( PDO $db ) : Phergie_Plugin_Karma Sets the connection to the plugin database, mainly intended for unit testing.

Protected Methods

Method Description
compareKarma ( string $term0, string $term1, string $method ) : void Compares the karma between two terms. Optionally increases/decreases the karma of either term.
fetchFixedKarma ( string $term ) : string Returns a phrase describing the karma rating for a specified term for which the karma rating is fixed.
fetchKarma ( string $term ) : integer | boolean Returns the karma rating for a specified term for which the karma rating can be modified.
getCanonicalTerm ( string $term ) : string Get the canonical form of a given term.
initializePreparedStatements ( ) : void Initializes prepared statements used by the plugin.
modifyKarma ( string $term, string $action ) : integer Modifes a term's karma.

Method Details

compareKarma() protected method

Compares the karma between two terms. Optionally increases/decreases the karma of either term.
protected compareKarma ( string $term0, string $term1, string $method ) : void
$term0 string First term
$term1 string Second term
$method string Comparison method (< or >)
return void

fetchFixedKarma() protected method

Returns a phrase describing the karma rating for a specified term for which the karma rating is fixed.
protected fetchFixedKarma ( string $term ) : string
$term string Term for which to fetch the corresponding karma rating
return string Phrase describing the karma rating, which may be append to the term to form a complete response

fetchKarma() protected method

Returns the karma rating for a specified term for which the karma rating can be modified.
protected fetchKarma ( string $term ) : integer | boolean
$term string Term for which to fetch the corresponding karma rating
return integer | boolean Integer value denoting the term's karma or FALSE if there is the specified term has no associated karma rating

getCanonicalTerm() protected method

In the canonical form all sequences of whitespace are replaced by a single space and all characters are lowercased.
protected getCanonicalTerm ( string $term ) : string
$term string Term for which a canonical form is required
return string Canonical term

getDb() public method

Returns a connection to the plugin database, initializing one if none is explicitly set.
public getDb ( ) : PDO
return PDO Database connection

initializePreparedStatements() protected method

Initializes prepared statements used by the plugin.
protected initializePreparedStatements ( ) : void
return void

modifyKarma() protected method

Modifes a term's karma.
protected modifyKarma ( string $term, string $action ) : integer
$term string Term to modify
$action string Karma action (either ++ or --)
return integer Modified karma rating

onCommandKarma() public method

Get the karma rating for a given term.
public onCommandKarma ( string $term ) : void
$term string Term for which the karma rating needs to be retrieved
return void

onCommandReincarnate() public method

Resets the karma for a term to 0.
public onCommandReincarnate ( string $term ) : void
$term string Term for which to reset the karma rating
return void

onLoad() public method

Check for dependencies and initializes a database connection and prepared statements.
public onLoad ( ) : void
return void

onPrivmsg() public method

Intercepts a message and processes any contained recognized commands.
public onPrivmsg ( ) : void
return void

setDb() public method

Sets the connection to the plugin database, mainly intended for unit testing.
public setDb ( PDO $db ) : Phergie_Plugin_Karma
$db PDO Database connection
return Phergie_Plugin_Karma Provides a fluent interface

Property Details

$db protected_oe property

SQLite object
protected resource $db
return resource

$fetchFixedKarma protected_oe property

Retrieves an existing fixed karma record
protected PDOStatement $fetchFixedKarma
return PDOStatement

$fetchKarma protected_oe property

Retrieves an existing karma record
protected PDOStatement $fetchKarma
return PDOStatement

$fetchNegativeAnswer protected_oe property

Retrieves a negative answer for a karma comparison
protected PDOStatement $fetchNegativeAnswer
return PDOStatement

$fetchPositiveAnswer protected_oe property

Retrieves a positive answer for a karma comparison
protected PDOStatement $fetchPositiveAnswer
return PDOStatement

$insertKarma protected_oe property

Prepared statement to add a new karma record
protected PDOStatement $insertKarma
return PDOStatement

$updateKarma protected_oe property

Prepared statement to update an existing karma record
protected PDOStatement $updateKarma
return PDOStatement