/** * @param $annuityPeriodLength */ public function setAnnuityPeriodLength(TimeSpan $annuityPeriodLength) { if (Helpers::checkIfNotNegativeNumberOrThrowAnException((string) $annuityPeriodLength)) { if (Helpers::checkIfZero($this->annuityNoOfCompoundingPeriods)) { $annuityPeriodLength = TimeSpan::asDuration(0); } $this->setProperty("annuityPeriodLength", $annuityPeriodLength); } }
/** * @param integer $years * @param integer $months * @param integer $days * @return TimeSpan */ public static function asDuration($years, $months = 0, $days = 0) { foreach (func_get_args() as $arg) { Helpers::checkIfNotNegativeNumberOrThrowAnException($arg); } $newThis = new TimeSpan(); $newThis->newDateIntervalAbsolute($years, $months, $days); return $newThis; }
public function testCheckIfNotNegativeNumberException() { $this->setExpectedException('InvalidArgumentException', ErrorMessages::getMustNotBeNegativeNumberMessage("-6")); Helpers::checkIfNotNegativeNumberOrThrowAnException(-6); }