fetchOrderCategorySteps = $fetchOrderCategorySteps; $this->listOrdersCategory = $listOrdersCategory; $this->listCompleteOrders = $listCompleteOrders; } /** * @param int $id * @param string $category * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection * @throws InternalServerErrorException */ public function execute(int $id, string $category){ try { switch ($category){ case OrderSteps::WAREHOUSE_COMPLETE_CATEGORY: return $this->listCompleteOrders->execute($id, $this->fetchOrderCategorySteps->execute($category)); default: return $this->listOrdersCategory->execute($id, $this->fetchOrderCategorySteps->execute($category)); } } catch (CannotListCompanyOrderCategoryException $exception){ throw new InternalServerErrorException('Cannot list warehouse\'s orders in '.$category.' category because'.$exception); } } }