laminas-filter
laminas-filter copied to clipboard
Filter for arithmetic operations
Feature Request
Q | A |
---|---|
New Feature | yes |
RFC | no |
BC Break | no |
Summary
I created this filter for an application that converts values from APIs. It's useful for measure unit conversions and making adjustments. For example, an endpoint returns the amount of RAM requested by an user and you can add a security margin.
https://github.com/laminas/laminas-filter/pull/29
Hi, @froschdesign. Where can I put documentation about this?
Tell me if something like this is enough.
Some value is given in meters but I want the value in kilometers. Think that value is given by an API that has no option for conversions. You don't have access a database to define the query.
Considering changes from your comments, I write a sample below:
require 'vendor/autoload.php';
use Laminas\Filter\FiveOperations;
$filter = new FiveOperations((['operation' => FiveOperations::DIV, 'value' => 1000]);
$distanceInMeters = 15450;
$distanceInKilometers = $filter->filter($distanceInMeters);
// $distanceInKilometers = 15.45