yana

phpDocumentor v 1.4.0

Class Counter

Description

counter wrapper
This class implements persistent counters - optional with IP checking - for various purposes: e.g. visitor counts, statistics, polls.
  • access: public
Object
   |
   --Counter
Method Summary
  • Counter Counter ([string $filename = ""], [int $use_ip = YANA_COUNTER_USE_IP])
  • int count (string $id, [string $info = ""], [int $ammount = 1])
  • string equals (object $anotherObject)
  • array get ([string $id = "*"])
  • mixed getCount ([string $id = "*"])
  • mixed getInfo ([string $id = "*"])

Methods

create a new instance
Counter Counter (
[string $filename = ""], [int $use_ip = YANA_COUNTER_USE_IP]
)
List of parameters:
Name Type Description
$filename string name of file to safe values to
$use_ip int count on reload on / off
Description:
Use the $use_ip parameter with the setting YANA_COUNTER_USE_IP to create a counter with IP checking (does'nt change on reload) or with the setting YANA_COUNTER_IGNORE_IP to create a counter without IP checking (always changes when an update is called).
Increment/Decrement counter
int count (
string $id, [string $info = ""], [int $ammount = 1]
)
List of parameters:
Name Type Description
$id string counter id
$info string optional description to be safed along with the counter
$ammount int number to add to counter
Description:
Adds $ammount (defaults to +1) to the counter $id and sets the counter description (the 'info' field) to $info (defaults to "").
Note: as you might already have guessed, using a negative value for $ammount decrements the counter.
  • access: public
compare with another object
string equals (
object $anotherObject
)
List of parameters:
Name Type Description
$anotherObject object any object or var you want to compare
Description:
Returns bool(true) if this object and $anotherObject are equal and bool(false) otherwise.
Two instances are considered equal if and only if they are both objects of the same class, they both refer to the same filesystem resource and use the same IP settings.
  • access: public

Redefinition of: Object::equals()

get counter
array get (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string counter id
Description:
Returns the current counter settings as:
 Array(
    'COUNT' => int
    'INFO'  => string
 )
Note: you may use the wildcard '*' to get all counters as an associative, multidimensional array:
 Array(
    ID1 => Array(
        'COUNT' => int
        'INFO'  => string
    )
    ID2 => Array(
        'COUNT' => int
        'INFO'  => string
    )
    ...
 )
  • access: public
get counter value
mixed getCount (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string counter id
Description:
This function returns the current value of counter $key.
Note: you may use the wildcard '*' to get an associative array for all values:
 Array(
    ID1 => int
    ID2 => int
    ...
 )
  • access: public
get counter info
mixed getInfo (
[string $id = "*"]
)
List of parameters:
Name Type Description
$id string counter id
Description:
The 'info' field is an optional text value, that describes the counter.
This function returns the current description of counter $key.
Note: you may use the wildcard '*' to get an associative array for all counters:
 Array(
    ID1 => string
    ID2 => string
    ...
 )
  • access: public
inherited from base classes

Inherited From Object

Documentation generated on Sat, 03 Jan 2009 22:22:13 +0100 by phpDocumentor 1.4.0

yana author: Thomas MeyerHomepage: www.yanaframework.net