Permalink
Browse files

新增ShippingService.php

  • Loading branch information...
oomusou committed Apr 5, 2016
1 parent fa4b0f8 commit 038eecfcabbcb867a6505456cfba78587d1c26bc
Showing with 30 additions and 0 deletions.
  1. +30 −0 app/Services/ShippingService.php
@@ -0,0 +1,30 @@
<?php
namespace App\Services;
use Exception;
class ShippingService
{
/**
* @param string $companyName
* @param int $weight
* @return int
* @throws Exception
*/
public function calculateFee($companyName, $weight)
{
if ($companyName == 'BlackCat') {
$blackCat = new BlackCat();
return $blackCat->calculateFee($weight);
} elseif ($companyName == 'Hsinchu') {
$hsinchu = new Hsinchu();
return $hsinchu->calculateFee($weight);
} elseif ($companyName == 'PostOffice') {
$postOffice = new PostOffice();
return $postOffice->calculateFee($weight);
} else {
throw new Exception('No company exception');
}
}
}

0 comments on commit 038eecf

Please sign in to comment.