interface CounterInterface in Purge 8.3
Describes a numeric counter.
Hierarchy
- interface \Drupal\purge\Counter\CounterInterface
Expanded class hierarchy of CounterInterface
All classes that implement CounterInterface
1 file declares its use of CounterInterface
- RuntimeMeasurementInterface.php in src/
Plugin/ Purge/ Purger/ RuntimeMeasurementInterface.php
File
- src/
Counter/ CounterInterface.php, line 8
Namespace
Drupal\purge\CounterView source
interface CounterInterface {
/**
* Construct a counter object.
*
* @param int|float $value
* The initial positive number the counter starts its life with.
*/
public function __construct($value = 0.0);
/**
* Disable the possibility to decrement the counter.
*
* @warning
* This works self-destructive! Once called, it cannot be enabled again.
*/
public function disableDecrement();
/**
* Disable the possibility to increment the counter.
*
* @warning
* This works self-destructive! Once called, it cannot be enabled again.
*/
public function disableIncrement();
/**
* Disable the possibility of setting counter.
*
* @warning
* This works self-destructive! Once called, it cannot be enabled again.
*/
public function disableSet();
/**
* Get the current value.
*
* @return float
* The numeric value of the counter.
*/
public function get();
/**
* Get the current value as integer.
*
* @return int
* The numeric value of the counter, typecasted as int.
*/
public function getInteger();
/**
* Overwrite the counter value.
*
* @param int|float $value
* The new value.
*
* @throws \Drupal\purge\Plugin\Purge\Purger\Exception\BadBehaviorException
* Thrown when $value is not a integer, float or when it is negative.
* @throws \LogicException
* Thrown when the object got created without set permission.
*/
public function set($value);
/**
* Set the callback that gets called when writes occur.
*
* The callback is called every time the counter changes value. The single
* only parameter passed to your callable is $value, you can use PHP's use
* statement to make any local variables available to it.
*
* @param callable $callback
* Any PHP callable.
*/
public function setWriteCallback(callable $callback);
/**
* Decrease the counter.
*
* @param int|float $amount
* Numeric amount to subtract from the current counter value.
*
* @throws \Drupal\purge\Plugin\Purge\Purger\Exception\BadBehaviorException
* Thrown when $amount is not a float, integer or when it is zero/negative.
* @throws \LogicException
* Thrown when the object got created without decrement permission.
*/
public function decrement($amount = 1.0);
/**
* Increase the counter.
*
* @param int|float $amount
* Numeric amount to add up to the current counter value.
*
* @throws \Drupal\purge\Plugin\Purge\Purger\Exception\BadBehaviorException
* Thrown when $amount is not a float, integer, when it is zero/negative.
* @throws \LogicException
* Thrown when the object got created without increment permission.
*/
public function increment($amount = 1.0);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CounterInterface:: |
public | function | Decrease the counter. | 1 |
CounterInterface:: |
public | function | Disable the possibility to decrement the counter. | 1 |
CounterInterface:: |
public | function | Disable the possibility to increment the counter. | 1 |
CounterInterface:: |
public | function | Disable the possibility of setting counter. | 1 |
CounterInterface:: |
public | function | Get the current value. | 1 |
CounterInterface:: |
public | function | Get the current value as integer. | 1 |
CounterInterface:: |
public | function | Increase the counter. | 1 |
CounterInterface:: |
public | function | Overwrite the counter value. | 1 |
CounterInterface:: |
public | function | Set the callback that gets called when writes occur. | 1 |
CounterInterface:: |
public | function | Construct a counter object. | 1 |