Skip to content

Commit

Permalink
change calculation result interface
Browse files Browse the repository at this point in the history
  • Loading branch information
moriony committed Jan 14, 2016
1 parent c0f1d18 commit 639c213
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/CalculatorHandler/AramexCalculatorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function visit(CalculationResultInterface $result, PackageInterface $pack
$this->validateWeight($package);
$price = $this->getPrice($package);

$result->setTotalCost($price);
$result->setShippingCost($price);
$result->setCurrency($this->get('currency'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/CalculatorHandler/AsendiaCalculatorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function visit(CalculationResultInterface $result, PackageInterface $pack
$fuelCost = $math->mul($wholeWeight, $this->get('fuel_subcharge'));
$total = $math->sum($cost, $fuelCost);

$result->setTotalCost($total);
$result->setShippingCost($total);
$result->setCurrency($this->get('currency'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/CalculatorHandler/DhlCalculatorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function visit(CalculationResultInterface $result, PackageInterface $pack
$zoneCalculator = $this->getZoneCalculator($package);
$total = $zoneCalculator->calculate($weight);

$result->setTotalCost($total);
$result->setShippingCost($total);
$result->setCurrency($this->get('currency'));
}

Expand Down
2 changes: 1 addition & 1 deletion src/CalculatorHandler/IParcelCalculatorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public function visit(CalculationResultInterface $result, PackageInterface $pack
$this->validateWeight($package);
$price = $this->getPrice($package);

$result->setTotalCost($price);
$result->setShippingCost($price);
$result->setCurrency($this->get('currency'));
}

Expand Down
12 changes: 6 additions & 6 deletions src/Model/CalculationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CalculationResult implements CalculationResultInterface
/**
* @var string|int|float
*/
protected $totalCost;
protected $shippingCost;

/**
* @var BasicExceptionInterface
Expand All @@ -27,22 +27,22 @@ class CalculationResult implements CalculationResultInterface
protected $currency;

/**
* @param string|int|float $totalCost
* @param string|int|float $cost
* @return $this
*/
public function setTotalCost($totalCost)
public function setShippingCost($cost)
{
$this->totalCost = $totalCost;
$this->shippingCost = $cost;

return $this;
}

/**
* @return string|int|float
*/
public function getTotalCost()
public function getShippingCost()
{
return $this->totalCost;
return $this->shippingCost;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Model/CalculationResultInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public function setCurrency($currency);
public function getCurrency();

/**
* @param string|int|float $totalCost
* @param string|int|float $cost
* @return $this
*/
public function setTotalCost($totalCost);
public function setShippingCost($cost);

/**
* @return string|int|float
*/
public function getTotalCost();
public function getShippingCost();

/**
* @param PackageInterface $package
Expand Down
2 changes: 1 addition & 1 deletion tests/CalculatorHandler/AramexCalculatorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testVisit($package, $expectedCost)

$this->assertInstanceOf('EsteIt\ShippingCalculator\Model\CalculationResultInterface', $result);
$this->assertNull($result->getError());
$this->assertSame($expectedCost, $result->getTotalCost());
$this->assertSame($expectedCost, $result->getShippingCost());
$this->assertSame('USD', $result->getCurrency());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CalculatorHandler/AsendiaCalculatorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testVisit()

$this->assertInstanceOf('EsteIt\ShippingCalculator\Model\CalculationResultInterface', $result);
$this->assertNull($result->getError());
$this->assertSame(22.1, $result->getTotalCost());
$this->assertSame(22.1, $result->getShippingCost());
$this->assertSame('USD', $result->getCurrency());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CalculatorHandler/DhlCalculatorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testVisit($package, $expectedCost)

$this->assertInstanceOf('EsteIt\ShippingCalculator\Model\CalculationResultInterface', $result);
$this->assertNull($result->getError());
$this->assertSame($expectedCost, $result->getTotalCost());
$this->assertSame($expectedCost, $result->getShippingCost());
$this->assertSame('USD', $result->getCurrency());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CalculatorHandler/IParcelCalculatorHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function testVisit($package, $expectedCost)

$this->assertInstanceOf('EsteIt\ShippingCalculator\Model\CalculationResultInterface', $result);
$this->assertNull($result->getError());
$this->assertSame($expectedCost, $result->getTotalCost());
$this->assertSame($expectedCost, $result->getShippingCost());
$this->assertSame('USD', $result->getCurrency());
}

Expand Down

0 comments on commit 639c213

Please sign in to comment.