Last active
May 7, 2019 12:56
-
-
Save avosalmon/c2e2296d96ab288bed1dd11bf007a333 to your computer and use it in GitHub Desktop.
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
<?php | |
interface OrderValidationInterface | |
{ | |
public function validate(Order $order) : void; | |
} | |
class OrderHasAmount implements OrderValidationInterface | |
{ | |
public function validate(Order $order) : void | |
{ | |
if (! $order->getAmount() > 0) { | |
throw new Exception('Order amount must be more than zero.'); | |
} | |
} | |
} | |
class OrderIsApproved implements OrderValidationInterface | |
{ | |
public function validate(Order $order) : void | |
{ | |
if (! $order->isApproved()) { | |
throw new Exception('Order is not approved.'); | |
} | |
} | |
} | |
class OrderIsNotCancelled implements OrderValidationInterface | |
{ | |
public function validate(Order $order) : void | |
{ | |
if (! $order->isCancelled()) { | |
throw new Exception('Cancelled order cannot be processed.'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment