Download the PHP package rumd3x/php-countable without Composer
On this page you can find all versions of the php package rumd3x/php-countable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rumd3x/php-countable
More information about rumd3x/php-countable
Files in rumd3x/php-countable
Package php-countable
Short Description Library providing several Object Oriented utilities for Counting stuff
License MIT
Informations about the package php-countable
php-countable
Library providing several Object Oriented utilities for Counting stuff.
Install
Usage Examples
-
As a while loop exit condition:
- As an iterator counter:
API Description
This Library provides:
- 2 counter interfaces
Decrementable
andIncrementable
. - A basic
AbstractCounter
that can be extended upon. - 4 counter implementations, all of them implementing both interfaces, and using
AbstractCounter
as a base.
The Incrementable
and Decrementable
interfaces provides the following methods:
Each Counter implementation handles incrementing and decrementing the counter differently:
BasicCounter
Rumd3x\Countable\Counters\BasicCounter
It is the most basic implementation of both Incrementable and Decrementable interfaces, it does not do any transformation with your inputs, and does not raise any Exceptions.
StandardCounter
Rumd3x\Countable\Counters\StandardCounter
StandardCounter holds a counter, and can increment or decrement its value by implementing both Incrementable and Decrementable interfaces. It can also count to negatives.
SmartCounter
Rumd3x\Countable\Counters\SmartCounter
SmartCounter is the same as StandardCounter, but it does not throw Rumd3x\Countable\Exceptions\NegativeQuantityException
when trying to increment or decrement by negatives, instead it swiftly converts the value to a positive one.
AbsoluteCounter
Rumd3x\Countable\Counters\AbsoluteCounter
The AbsoluteCounter is just like a StandardCounter but throws Rumd3x\Countable\Exceptions\NegativeCounterExpcetion
if tries the program tries to decrement past 0. It ensures the counter is always positive.
AbstractCounter
The AbstractCounter
implements the following methods below:
(Which makes it also available for all 4 Counter implementations provided by the library)