dev-master
9999999-devService to divide a given amount into given parts
MIT
The Requires
- php >=5.4
The Development Requires
by Matthias Derer
Service to divide a given amount into given parts
, (*1)
The Divider
class can be used to divide a certain amount into smaller parts, that can be defined., (*2)
You can use it for example to divide an amount of money into possible coins and notes. The default parts when instantiating a Divider
instance are all possible € coins and notes., (*3)
Example:, (*4)
<?php $divider = new Divider(); $result = $divider->divide(30); // [20 => 1, 10 => 1]
The class only handles integers, so if you are working with € keep in mind that the input as well as output is considered being cents., (*5)
Divider
also handles rest values:, (*6)
<?php $divider = new Divider([3]); $result = $divider->divide(4); // [3=>1, "REST" => 1]
Service to divide a given amount into given parts
MIT