interface FractionInterface in Fraction 2.x
Same name and namespace in other branches
- 8 src/FractionInterface.php \Drupal\fraction\FractionInterface
Defines the interface for Fraction class.
@package fraction
Hierarchy
- interface \Drupal\fraction\FractionInterface
Expanded class hierarchy of FractionInterface
All classes that implement FractionInterface
File
- src/
FractionInterface.php, line 10
Namespace
Drupal\fractionView source
interface FractionInterface {
/**
* Sets the numerator.
*
* @param string|int $numerator
* The numerator value.
*
* @return Fraction
* Returns this Fraction object.
*/
public function setNumerator($numerator);
/**
* Sets the denominator.
*
* @param string|int $denominator
* The denominator value.
*
* @return Fraction
* Returns this Fraction object.
*/
public function setDenominator($denominator);
/**
* Gets the numerator.
*
* @return string
* Returns the numerator value.
*/
public function getNumerator();
/**
* Gets the denominator.
*
* @return string
* Returns the denominator value.
*/
public function getDenominator();
/**
* Return a string representation of the fraction.
*
* @param string $separator
* The separator to place between the numerator and denominator.
*
* @return string
* Returns a string with the numerator, separator, and denominator.
*/
public function toString(string $separator = '/');
/**
* Calculates the decimal equivalent of the fraction.
*
* @param int $precision
* The desired decimal precision, defaults to 0.
* @param bool $auto_precision
* Boolean, whether or not the precision should be automatically calculated.
* This option provides more precision when you need it, and less when you
* don't. If set to TRUE, it will try to determine the maximum precision
* (this only works if the denominator is base 10). If the resulting
* precision is greater than $precision, it will be used instead.
*
* @return string
* Returns the decimal equivalent of the fraction as a PHP string.
*/
public function toDecimal(int $precision, bool $auto_precision = FALSE);
/**
* Calculates the numerator and denominator from a decimal value.
*
* @param string|int|float $value
* The decimal value to start with.
*
* @return Fraction
* Returns this object.
*/
public static function createFromDecimal($value);
/**
* Calculate the fraction's greatest common divisor using Euclid's algorithm.
*
* @return string
* Returns the greatest common divisor.
*/
public function gcd();
/**
* Reduces the fraction to its simplest form.
*
* @return Fraction
* Returns this Fraction object.
*/
public function reduce();
/**
* Reciprocates the fraction.
*
* @return Fraction
* Returns this Fraction object.
*/
public function reciprocate();
/**
* Adds another fraction to this one.
*
* @param Fraction $fraction
* Another fraction object to add to this one.
*
* @return Fraction
* Returns this Fraction object.
*/
public function add(Fraction $fraction);
/**
* Subtracts another fraction from this one.
*
* @param Fraction $fraction
* Another fraction object to subtract this one.
*
* @return Fraction
* Returns this Fraction object.
*/
public function subtract(Fraction $fraction);
/**
* Multiplies this fraction with another one.
*
* @param Fraction $fraction
* Another fraction object to multiply with.
*
* @return Fraction
* Returns this Fraction object.
*/
public function multiply(Fraction $fraction);
/**
* Divides this fraction by another one.
*
* @param Fraction $fraction
* Another fraction object to divide by.
*
* @return Fraction
* Returns this Fraction object.
*/
public function divide(Fraction $fraction);
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FractionInterface:: |
public | function | Adds another fraction to this one. | 1 |
FractionInterface:: |
public static | function | Calculates the numerator and denominator from a decimal value. | 1 |
FractionInterface:: |
public | function | Divides this fraction by another one. | 1 |
FractionInterface:: |
public | function | Calculate the fraction's greatest common divisor using Euclid's algorithm. | 1 |
FractionInterface:: |
public | function | Gets the denominator. | 1 |
FractionInterface:: |
public | function | Gets the numerator. | 1 |
FractionInterface:: |
public | function | Multiplies this fraction with another one. | 1 |
FractionInterface:: |
public | function | Reciprocates the fraction. | 1 |
FractionInterface:: |
public | function | Reduces the fraction to its simplest form. | 1 |
FractionInterface:: |
public | function | Sets the denominator. | 1 |
FractionInterface:: |
public | function | Sets the numerator. | 1 |
FractionInterface:: |
public | function | Subtracts another fraction from this one. | 1 |
FractionInterface:: |
public | function | Calculates the decimal equivalent of the fraction. | 1 |
FractionInterface:: |
public | function | Return a string representation of the fraction. | 1 |