Releases: dereuromark/cakephp-decimal
2.3.0
Improvements
Shimmed CakePHP 5.3 number helper functionality regarding "null / empty".
In your AppView.php:
$this->loadHelper('CakeDecimal.Number');instead of the core one.
You have now the empty functionality of CakePHP 5.3+ in your Number helper:
- format()
- currency()
Instead of ternary checks you can pass your DB values directly, it will print out
an empty string (or defined default string) where needed.
echo $this->Number->format($entity->value);
// or
echo $this->Number->format($entity->value, ['default' => '-']);and
echo $this->Number->currency($entity->value);
// or
echo $this->Number->currency($entity->value, ['default' => '-']);This aims to provide forward compatibility.
2.2.0
Improvements
Auto Column Mapping
Now auto-maps column by default. Disable by loading the plugin without its bootstrap.
Helper Trait
Moved methods into NumberHelperTrait for easier project level inclusion for existing helper.
Nothing changes for existing usage.
If you already have a local helper, you can use the trait to add them on top, now:
namespace App\View\Helper;
use Cake\View\Helper\NumberHelper as CoreNumberHelper;
use CakeDecimal\View\Helper\NumberHelperTrait;
class NumberHelper extends CoreNumberHelper {
use NumberHelperTrait;
... // other methods or replacement of trait methods
}2.1.0
1.2.0
Improvements
WARNING This is not BC and needs to be pulled manually. If you want to stay on the previous minor, use ~1.1.0 in your composer.json as constraint.
Now uses php-collective/decimal-object as maintained PHP 8.1+ dependency.
- Use maintained lib for decimal object value
- Added NumberHelper for convenience.
- PHP 8.1+
- CakePHP 4.4+
- Deprecations removed
Important notes:
As outlined above, you need to replace Spryker\ with PhpCollective\ in your PHP files in order for the upgrade path to be smooth.
Full Changelog: 1.1.0...1.2.0
2.0.0
CakePHP 5 compatible release
Now uses php-collective/decimal-object as maintained PHP 8.1+ dependency.
Main advantages/features now:
- Strict typing where feasible due to PHP 8.1+
- Stringable interface for better compatibility with "as string" usage
- Also accepts any Stringable numeric object as input
1.1.0
Improvements
- CakePHP 4.2+
- PHP 7.4+
1.0.1
Improvements
Adjusted composer type to "cakephp-plugin".
1.0.0
CakePHP 4 stable release
This is an alternative to
- the core Decimal type (using plain strings)
As value object you have a few advantages, especially on handling the values inside your business logic.
Uses spryker/decimal-object and as such requires bcmath extension.
1.0.0-beta
CakePHP 4 compatible pre-release.
Please help to finalize for stable release.
0.1.0
Initial Release
This is an alternative
- to the core one (using float in 3.x and string in 4.x)
- and Shim plugin (using string in 3.x just like 4.x will).
As value object you have a few advantages, especially on handling the values inside your business logic.
$decimal = Decimal::create(22),
$decimal = $decimal->add(...);
// in the view echo or use formatter wrapper
echo $decimal;Uses spryker/decimal-object and as such requires bcmath extension.