Skip to content

Instantly share code, notes, and snippets.

@avosalmon
Created May 6, 2019 23:41
Show Gist options
  • Save avosalmon/eebccc8b39d19b4f1a7ca7aade75d665 to your computer and use it in GitHub Desktop.
Save avosalmon/eebccc8b39d19b4f1a7ca7aade75d665 to your computer and use it in GitHub Desktop.
OrderProcessor class after refactoring.
<?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