Skip to content

Instantly share code, notes, and snippets.

@avosalmon
Created May 6, 2019 23:41

Revisions

  1. Ryuta Hamasaki created this gist May 6, 2019.
    20 changes: 20 additions & 0 deletions OrderProcessor_Refactored.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?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);
    }
    }