-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added more examples, fixed old ones (#3)
- Loading branch information
Nicolò Pignatelli
authored
Dec 4, 2019
1 parent
9865f66
commit b55a18f
Showing
5 changed files
with
67 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
use Careship\Functional\Either\Reason; | ||
use Careship\Functional\Result\Result; | ||
use function Careship\Functional\Result\handle_result; | ||
|
||
interface OrderService { | ||
function setOrderToShipped(string $orderId): Result; | ||
} | ||
|
||
final class ShipOrderController | ||
{ | ||
/** @var OrderService */ | ||
private $orderService; | ||
|
||
public function __construct(OrderService $orderService) | ||
{ | ||
$this->orderService = $orderService; | ||
} | ||
|
||
public function __invoke(string $orderId): JsonResponse | ||
{ | ||
return handle_result( | ||
$this->orderService->setOrderToShipped($orderId), | ||
function () { | ||
return JsonResponse('ok'); | ||
}, | ||
function (Reason $reason) { | ||
return JsonResponse('error: ' . $reason->toString()); | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters