Download the PHP package nicmart/numbers without Composer

On this page you can find all versions of the php package nicmart/numbers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package numbers

Numbers

Build Status Coverage Status Scrutinizer Quality Score

Numbers provides a simple and powerful way to convert numbers in various string formats, like scientific notation or unit-suffix notation.

It also gives you control on numbers precision (that's different of the numbers of decimals!), making it simple to format numbers as you want in your view layer.

For installing instructions, please go to the end of this README.

Usage

First, instantiate an object of the Number class. You can do it in two ways: directly or using the n static method:

You can then retrieve the underlying float/int value using the get method:

Significant figures

You can set the number of significant figures using the method round.

As you can see, the round method works differently from the php builtin roundfunction, since you are not setting the number of decimals, but the number of significant figures:

Scientific notation

You can easily convert a Number to Scientific Notation:

A SciNotation objects convert themselves to html when casted to strings:
(string) Number::n(1234.567)->getSciNotation() → 1.234567 × 104
(string) Number::n(0.000023)->getSciNotation() → 2.3 × 10-5

Suffix notation

With suffix notation you can convert a number to a format using the metric prefix notation. What you will get is a number followed by a suffix that indicates the magnitude of that number, using the "kilo", "mega", etc... symbols. All the SI symbols are supported.

Format with thousands and decimals separator

The format method works like number_format, but without the hassle of specifying the number of decimals. The number of significant figures will be used instead. Furthermore, it will not print trailing zeros in the decimal part.

By default format fallbacks to . and , separators if some argument is missing. If you want instead to fallback to the current locale settings of the machine, you can use localeFormat.

Other functions

Floor and Ceil

They behave like their mathematical counterparts and the builtin php functions:

Magnitude

Gives the order of magnitude of the number (that is equal to the exponent of 10 in the Scientific Notation):

n-th digit

Gives the n-th digit of the number in a given base

Sign

The sign function, as defined in mathematics

Apply

Apply a callback to the underlying scalar number, in a Monad fashion:

Install

The best way to install Numbers is through composer.

Just create a composer.json file for your project:

Then you can run these two commands to install it:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar install

or simply run composer install if you have have already installed the composer globally.

Then you can include the autoloader, and you will have access to the library classes:


All versions of numbers with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nicmart/numbers contains the following files

Loading the files please wait ....