Permalink
Browse files

重構 ShippingService 使用 closure

  • Loading branch information...
1 parent ffabd0f commit fb691e1027ee6f5e1025bbf8f4c80c2cbd1fce18 Sam.IO.Hsiao committed Nov 18, 2016
Showing with 3 additions and 3 deletions.
  1. +3 −3 app/Services/ShippingService.php
@@ -9,11 +9,11 @@ class ShippingService
/**
* 計算運費
* @param int $weight
- * @param LogisticsInterface $logistics
+ * @param callable $logistics
* @return int
*/
- public function calculateFee(int $weight, LogisticsInterface $logistics) : int
+ public function calculateFee(int $weight, callable $logistics) : int
{
- return $logistics->calculateFee($weight);
+ return $logistics($weight);
}
}

0 comments on commit fb691e1

Please sign in to comment.