Created
May 6, 2019 23:41
-
-
Save avosalmon/eebccc8b39d19b4f1a7ca7aade75d665 to your computer and use it in GitHub Desktop.
OrderProcessor class after refactoring.
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 | |
class OrderProcessor | |
{ | |
public function __construct(array $validators, OrderNotificationInterface $notification) { | |
$this->$validators = $validators; | |
$this->notification = $notification; | |
} | |
public function process(Order $order) | |
{ | |
foreach ($this->validators as $validator) { | |
$validator->validate($order); | |
} | |
$order->update(); | |
$this->notification->notify($order); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment