Permalink
Browse files

新增LogisticsFactory.php

  • Loading branch information...
oomusou committed Apr 5, 2016
1 parent 24656ce commit 9da99ca17a25ba8c65d852007ebc34a4558f8306
Showing with 27 additions and 0 deletions.
  1. +27 −0 app/Services/LogisticsFactory.php
@@ -0,0 +1,27 @@
<?php
namespace App\Services;
use Exception;
class LogisticsFactory
{
/**
* @param string $companyName
* @return LogisticsInterface
* @throws Exception
*/
public static function create(string $companyName) : LogisticsInterface
{
switch ($companyName) {
case 'BlackCat':
return new BlackCat();
case 'Hsinchu':
return new Hsinchu();
case 'PostOffice':
return new PostOffice();
default:
throw new Exception('No company exception');
}
}
}

0 comments on commit 9da99ca

Please sign in to comment.