Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
ARG PHP_VERSION=8.2
ARG PHPUNIT_VERSION=10.4.0
ARG PHPSTAN_VERSION=1.10.38
ARG PHP_VERSION=8.5

FROM php:${PHP_VERSION}-cli-alpine
COPY --from=composer /usr/bin/composer /usr/bin/composer

ARG PHPUNIT_VERSION
ARG PHPSTAN_VERSION

RUN docker-php-ext-install bcmath && docker-php-ext-enable bcmath
RUN wget -O phpunit https://phar.phpunit.de/phpunit-${PHPUNIT_VERSION}.phar && chmod +x phpunit
RUN wget -O phpstan https://github.com/phpstan/phpstan/releases/download/${PHPSTAN_VERSION}/phpstan.phar && chmod +x phpstan

4 changes: 1 addition & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
PHP_VERSION=8.2
PHPUNIT_VERSION=10.4.0
PHPSTAN_VERSION=1.10.38
PHP_VERSION=8.5
18 changes: 9 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ on:

jobs:
testsuite:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['8.1', '8.3', '8.5']
php-version: ['8.2', '8.3', '8.4', '8.5']

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -32,29 +32,29 @@ jobs:

- name: Run PHPUnit
run: |
if [[ ${{ matrix.php-version }} == '8.1' ]]; then
if [[ ${{ matrix.php-version }} == '8.2' ]]; then
vendor/bin/phpunit --coverage-clover=coverage.xml
else
vendor/bin/phpunit
fi

- name: Code Coverage Report
if: success() && matrix.php-version == '8.1'
uses: codecov/codecov-action@v4
if: success() && matrix.php-version == '8.2'
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}

validation:
name: Coding Standard & Static Analysis
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
extensions: mbstring, intl, bcmath
coverage: none

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![CI](https://github.com/php-collective/decimal-object/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/php-collective/decimal-object/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/php-collective/decimal-object/branch/master/graph/badge.svg?token=L1thFB9nOG)](https://codecov.io/gh/php-collective/decimal-object)
[![Latest Stable Version](https://poser.pugx.org/php-collective/decimal-object/v/stable.svg)](https://packagist.org/packages/php-collective/decimal-object)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/)
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.2-8892BF.svg)](https://php.net/)
[![PHPStan](https://img.shields.io/badge/PHPStan-level%208-brightgreen.svg?style=flat)](https://phpstan.org/)
[![License](https://poser.pugx.org/php-collective/decimal-object/license)](https://packagist.org/packages/php-collective/decimal-object)

Expand All @@ -26,7 +26,7 @@ Monetary values themselves could be handled also with [brick/money](https://gith

For details see the [wiki](https://github.com/php-collective/decimal-object/wiki).

Note: If you are looking for pre PHP 8.1 versions, check out the [legacy library](https://github.com/spryker/decimal-object).
Note: PHP 8.1 is covered by the 1.3 releases. For anything older, check out the [legacy library](https://github.com/spryker/decimal-object).

## Features

Expand All @@ -40,6 +40,7 @@ Note: If you are looking for pre PHP 8.1 versions, check out the [legacy library

### Requirements

- PHP 8.2+
- `bcmath` PHP extension enabled

### Composer (preferred)
Expand Down
4 changes: 1 addition & 3 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ services:
context: .
dockerfile: .docker/Dockerfile
args:
PHP_VERSION: "${PHP_VERSION:-8.2}"
PHPUNIT_VERSION: "${PHPUNIT_VERSION:-10.4.0}"
PHPSTAN_VERSION: "${PHPSTAN_VERSION:-1.10.38}"
PHP_VERSION: "${PHP_VERSION:-8.5}"
volumes:
- ./:/code
working_dir: /code
18 changes: 15 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
"description": "PHP decimal handling as value object",
"license": "MIT",
"type": "library",
"keywords": [
"decimal",
"value-object",
"bcmath",
"precision",
"arbitrary-precision",
"math"
],
"authors": [
{
"name": "The PHP Collective",
Expand All @@ -13,15 +21,19 @@
"homepage": "https://spryker.com"
}
],
"support": {
"issues": "https://github.com/php-collective/decimal-object/issues",
"source": "https://github.com/php-collective/decimal-object"
},
"require": {
"php": ">=8.1",
"php": ">=8.2",
"ext-bcmath": "*",
"ext-json": "*"
},
"require-dev": {
"php-collective/code-sniffer": "^0.2.1",
"php-collective/code-sniffer": "^0.6.8",
"phpstan/phpstan": "^2.0.0",
"phpunit/phpunit": "^10.5.45 || ^11.0.0 || ^12.0.0 || ^13.0.0"
"phpunit/phpunit": "^11.5.0 || ^12.0.0 || ^13.0.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
Expand Down
2 changes: 2 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
colors="true"
bootstrap="vendor/autoload.php"
>
Expand Down
30 changes: 15 additions & 15 deletions src/Decimal.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function create(object|string|float|int $value, ?int $scale = null
*
* This method is equivalent to the `==` operator.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool TRUE if this decimal is considered equal to the given value.
* Equal decimal values tie-break on precision.
Expand All @@ -173,7 +173,7 @@ public function equals(self|string|float|int $value): bool
}

/**
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool
*/
Expand All @@ -183,7 +183,7 @@ public function greaterThan(self|string|float|int $value): bool
}

/**
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool
*/
Expand All @@ -193,7 +193,7 @@ public function lessThan(self|string|float|int $value): bool
}

/**
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool
*/
Expand All @@ -205,7 +205,7 @@ public function greaterThanOrEquals(self|string|float|int $value): bool
/**
* @deprecated Use {@link greaterThanOrEquals()} instead.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool
*/
Expand All @@ -215,7 +215,7 @@ public function greatherThanOrEquals(self|string|float|int $value): bool
}

/**
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return bool
*/
Expand All @@ -232,7 +232,7 @@ public function lessThanOrEquals(self|string|float|int $value): bool
* - `0` if the instance is equal to $value, or
* - `1` if the instance is greater than $value.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
*
* @return int
*/
Expand All @@ -247,7 +247,7 @@ public function compareTo(self|string|float|int $value): int
/**
* Add $value to this Decimal and return the sum as a new Decimal.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
* @param int|null $scale Decimal places in the result. Omit to enable auto-detection.
*
* @return static
Expand Down Expand Up @@ -281,7 +281,7 @@ protected function resultScale(self $a, self $b, ?int $scale = null): int
* Subtract $value from this Decimal and return the difference as a new
* Decimal.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
* @param int|null $scale Decimal places in the result. Omit to enable auto-detection.
*
* @return static
Expand Down Expand Up @@ -389,12 +389,12 @@ public function isPositive(): bool
/**
* Multiply this Decimal by $value and return the product as a new Decimal.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
* @param int|null $scale Decimal places in the result. Omit to enable auto-detection.
*
* @return static
*/
public function multiply(self|string|int|float $value, ?int $scale = null): static
public function multiply(self|string|float|int $value, ?int $scale = null): static
{
$decimal = static::create($value);
if ($scale === null) {
Expand All @@ -407,14 +407,14 @@ public function multiply(self|string|int|float $value, ?int $scale = null): stat
/**
* Divide this Decimal by $value and return the quotient as a new Decimal.
*
* @param static|string|float|int $value
* @param self|string|float|int $value
* @param int $scale Decimal places in the result
*
* @throws \DivisionByZeroError if $value is zero.
*
* @return static
*/
public function divide(self|string|int|float $value, int $scale): static
public function divide(self|string|float|int $value, int $scale): static
{
$decimal = static::create($value);
if ($decimal->isZero()) {
Expand All @@ -427,7 +427,7 @@ public function divide(self|string|int|float $value, int $scale): static
/**
* This method is equivalent to the ** operator.
*
* @param static|string|int $exponent
* @param self|string|int $exponent
* @param int|null $scale Decimal places in the result. Omit to enable auto-detection.
*
* @return static
Expand Down Expand Up @@ -460,7 +460,7 @@ public function sqrt(?int $scale = null): static
/**
* This method is equivalent to the % operator.
*
* @param static|string|int $value
* @param self|string|int $value
* @param int|null $scale Decimal places in the result. Omit to enable auto-detection.
*
* @return static
Expand Down
Loading
Loading