Download the PHP package elliotjreed/maths without Composer
On this page you can find all versions of the php package elliotjreed/maths. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elliotjreed/maths
More information about elliotjreed/maths
Files in elliotjreed/maths
Package maths
Short Description An object-oriented BCMath wrapper for PHP
License MIT
Homepage https://github.com/elliotjreed/maths
Informations about the package maths
Maths
This PHP package provides an object-oriented wrapper for bcmath
functionality and other common operations for dealing with numbers.
One aim of this project is to provide a greater degree of accuracy when dealing with floating point numbers.
Installation
To install the package via Composer, run:
or include the dependency in your composer.json
file, for example:
Usage
There are two base classes, Number
and NumberImmutable
.
Both can take any numeric value in the constructor (i.e. a numeric string such as '1.5'
, an integer such as 150
, a float such as 1.33
, or a scientific notation string such as '8.431e-05'
).
The result can be returned as a string, integer, or float.
For an example of the differences between Number
and NumberImmutable
:
Number
The Number
object is mutable.
Examples:
Numbers can be int
, float
, string
, or instances of Number
.
NumberImmutable
The NumberImmutable
class is immutable.
Examples:
Numbers can be int
, float
, string
, or instances of Number
.
Development
Getting Started
PHP 8.1 or above and Composer is expected to be installed.
Installing Composer
For instructions on how to install Composer visit getcomposer.org.
Installing
After cloning this repository, change into the newly created directory and run:
or if you have installed Composer locally in your current directory:
This will install all dependencies needed for the project.
Henceforth, the rest of this README will assume composer
is installed globally (ie. if you are using composer.phar
you will need to use composer.phar
instead of composer
in your terminal / command-line).
Running the Tests
Unit tests
Unit testing in this project is via PHPUnit.
All unit tests can be run by executing:
Debugging
To have PHPUnit stop and report on the first failing test encountered, run:
Code formatting
A standard for code style can be important when working in teams, as it means that less time is spent by developers processing what they are reading (as everything will be consistent).
Code formatting is automated via PHP-CS-Fixer. PHP-CS-Fixer will not format line lengths which do form part of the PSR-2 coding standards so these will product warnings when checked by PHP Code Sniffer.
These can be run by executing:
Running everything
All of the tests can be run by executing:
Outdated dependencies
Checking for outdated Composer dependencies can be performed by executing:
Validating Composer configuration
Checking that the composer.json is valid can be performed by executing:
Running via GNU Make
If GNU Make is installed, you can replace the above composer
command prefixes with make
.
All of the tests can be run by executing:
Running the tests on a Continuous Integration platform (eg. Github Actions)
Specific output formats better suited to CI platforms are included as Composer scripts.
To output unit test coverage in text and Clover XML format (which can be used for services such as Coveralls):
To output PHP-CS-Fixer (dry run) and PHPCS results in checkstyle format (which GitHub Actions will use to output a readable format):
Github Actions
Look at the example in .github/workflows/main.yml.
Built With
License
This project is licensed under the MIT License - see the LICENCE.md file for details.
All versions of maths with dependencies
ext-bcmath Version *