TaskActionFactory.php 579 B

12345678910111213141516171819202122
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\miniapi\service\driver;
  4. use app\miniapi\exception\ApiException;
  5. final class TaskActionFactory
  6. {
  7. public static function make(string $action): TaskAction
  8. {
  9. return match ($action) {
  10. 'start' => new StartDelivery(),
  11. 'checkin' => new CheckIn(),
  12. 'exception' => new ReportException(),
  13. 'draft' => new SaveFulfillment(false),
  14. 'complete' => new SaveFulfillment(true),
  15. default => throw new ApiException(40401, '操作不存在', 404),
  16. };
  17. }
  18. }