You are here

public function Fraction::toString in Fraction 8

Same name and namespace in other branches
  1. 2.x src/Fraction.php \Drupal\fraction\Fraction::toString()

Return a string representation of the fraction.

Parameters

string $separator: The separator to place between the numerator and denominator.

Return value

string Returns a string with the numerator, separator, and denominator.

Overrides FractionInterface::toString

File

src/Fraction.php, line 129

Class

Fraction
A simple class for representing and acting upon a fraction.

Namespace

Drupal\fraction

Code

public function toString(string $separator = '/') {

  // Get the numerator and denominator.
  $numerator = $this
    ->getNumerator();
  $denominator = $this
    ->getDenominator();

  // Concatenate with the separator and return.
  return $numerator . $separator . $denominator;
}