2017 © Pedro Peláez
 

library fraction

A composer-installable fractions library

image

phospr/fraction

A composer-installable fractions library

  • Wednesday, December 21, 2016
  • by tomhv
  • Repository
  • 2 Watchers
  • 10 Stars
  • 13,529 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 7 Forks
  • 5 Open issues
  • 11 Versions
  • 23 % Grown

The README.md

Phospr Fraction

Build Status Coverage Status, (*1)

Composer-installable fractions for PHP, (*2)

Usage

use Phospr\Fraction;

Simple Fractions

echo new Fraction(1, 2); // 1/2
echo new Fraction(5, 2); // 2 1/2

Create Fraction from string

echo Fraction::fromString('1 2/3'); // 1 2/3
echo Fraction::fromString('28/4'); // 7

Create Fraction from float

echo Fraction::fromFloat(1.5); // 1 1/2

Auto-simplified

Fractions are simplified at construction, (*3)

echo new Fraction(4, 6); // 2/3

Addition

$fraction = new Fraction(2, 7);
echo $fraction->add(new Fraction(3, 11)); // 43/77

Subtraction

$fraction = new Fraction(6);
echo $fraction->subtract(new Fraction(2, 3)); // 5 1/3

Multiplication

$fraction = new Fraction(1, 2);
echo $fraction->multiply(new Fraction(1, 2)); // 1/4

Division

$fraction = new Fraction(6, 13);
echo $fraction->divide(new Fraction(2, 7)); // 1 8/13

To Float

$fraction = new Fraction(1, 8);
$fraction->toFloat(); // 0.125

Is Integer?

Check whether a fraction is in fact a whole number., (*4)

$fraction = new Fraction(1, 8);
$fraction->isInteger(); // false

$fraction = new Fraction(16, 8);
$fraction->isInteger(); // true

Installation

Add package to your composer.json file, (*5)


{ "require": { "phospr/fraction": "dev-master" } }

The Versions

21/12 2016

v1.x-dev

1.9999999.9999999.9999999-dev

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

21/12 2016

dev-master

9999999-dev

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

21/12 2016

v1.2.1

1.2.1.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

20/12 2016

v1.2.0

1.2.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

09/02 2016

v1.1.0

1.1.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

10/01 2016

v1.0.0

1.0.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

10/01 2016

v0.5.0

0.5.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

09/01 2016

v0.4.0

0.4.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

08/01 2016

v0.3.0

0.3.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

31/12 2015

v0.2.0

0.2.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan

05/11 2015

v0.1.0

0.1.0.0

A composer-installable fractions library

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

by Tom Haskins-Vaughan