Skip to content

Commit

Permalink
– renamed converter methods in TimeSpan
Browse files Browse the repository at this point in the history
  • Loading branch information
uruba committed Sep 8, 2015
1 parent 2cf2362 commit 9dc6c68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Calculators/AnnuityCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,21 @@ public function getAnnuityNoOfCompoundingPeriods() {
* @return string
*/
public function getAnnuityPeriodLengthInYears() {
return $this->annuityPeriodLength->asYears();
return $this->annuityPeriodLength->toYears();
}

/**
* @return string
*/
public function getAnnuityPeriodLengthInMonths() {
return $this->annuityPeriodLength->asMonths();
return $this->annuityPeriodLength->toMonths();
}

/**
* @return mixed
*/
public function getAnnuityPeriodLengthInDays() {
return $this->annuityPeriodLength->asDays();
return $this->annuityPeriodLength->toDays();
}

/**
Expand Down
8 changes: 4 additions & 4 deletions src/Utils/Time/TimeSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function getDaysComponent() {
* @return string
* @throws Exception
*/
public function asYears() {
public function toYears() {
$monthsComponent = MathFuncs::div(
$this->getMonthsComponent(),
12
Expand All @@ -173,7 +173,7 @@ public function asYears() {
* @return string
* @throws Exception
*/
public function asMonths() {
public function toMonths() {
$yearsComponent = MathFuncs::mul($this->getYearsComponent(), 12);
$daysComponent = TimeUtils::getCurrentDayCountConvention()['days_in_a_month'] == 0 ?
0 :
Expand All @@ -189,7 +189,7 @@ public function asMonths() {
* @return string
* @throws Exception
*/
public function asDays() {
public function toDays() {
$yearsComponent = MathFuncs::mul(
$this->getYearsComponent(),
TimeUtils::getCurrentDayCountConvention()['days_in_a_year']
Expand Down Expand Up @@ -278,7 +278,7 @@ private function roundDateInterval(DateInterval $dateInterval) {
* @return string
*/
public function __toString() {
return $this->asDays();
return $this->toDays();
}
}
}
6 changes: 3 additions & 3 deletions tests/TimeUtilsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class TimeUtilsTest extends PHPUnit_Framework_TestCase {
private $DAYS = 360;

public function testYearsFromTimeSpan() {
$this->assertEquals(1.75, $this->timeSpan->asYears());
$this->assertEquals(1.75, $this->timeSpan->toYears());
}

public function testMonthsFromTimeSpan() {
$this->assertEquals(21, $this->timeSpan->asMonths());
$this->assertEquals(21, $this->timeSpan->toMonths());
}

public function testDaysFromTimeSpan() {
$this->assertEquals(630, $this->timeSpan->asDays());
$this->assertEquals(630, $this->timeSpan->toDays());
}

public function testGetYearsFromDays() {
Expand Down

0 comments on commit 9dc6c68

Please sign in to comment.