for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Del\Phi;
class Fraction
{
/** @var int $whole */
private $whole;
/** @var int $numerator */
private $numerator;
/** @var int $denominator */
private $denominator;
public function __construct($whole = 1, $numerator = 1, $denominator = 1)
$this->whole = $whole;
$this->numerator = $numerator;
$this->denominator = $denominator;
}
/**
* @return int
*/
public function getWhole()
return $this->whole;
* @param int $whole
* @return Fraction
public function setWhole($whole)
return $this;
public function getNumerator()
return $this->numerator;
* @param int $numerator
public function setNumerator($numerator)
public function getDenominator()
return $this->denominator;
* @param int $denominator
public function setDenominator($denominator)
* @return bool
public function isInteger()
return $this->numerator % $this->denominator == 0;
* @return string
public function __toString()
$whole = $this->whole == 0 ? '' : $this->whole.' ';
return $whole.$this->numerator.'/'.$this->denominator;
* @return float
public function toDecimal()
/*
* a divide symbol. so this is broken and will need refactoring to be accurate. ;-)
return $this->whole + ($this->numerator / $this->denominator);