Created
September 9, 2019 21:11
-
-
Save chrisharrison/a52a0e3d8208512601f82ccbb4191523 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 | |
final class ProduceAccountStatementHandler | |
{ | |
private $accountFinder; | |
private $pdfGenerator; | |
public function __construct( | |
AccountFinder $accountFinder, | |
PdfGenerator $pdfGenerator | |
) { | |
$this->accountFinder = $accountFinder; | |
$this->pdfGenerator = $pdfGenerator; | |
} | |
public function handle(Command $command): void | |
{ | |
$account = $this->accountFinder->byId($command->accountId()); | |
$accountTotal = 0; | |
foreach ($account->items as $item) { | |
$accountTotal += $item->total(); | |
} | |
$this->pdfGenerator->generate('account-statement.template', $account, $accountTotal); | |
} | |
} | |
final class ProducePaymentOverdueNoticeHandler | |
{ | |
private $accountFinder; | |
private $pdfGenerator; | |
public function __construct( | |
AccountFinder $accountFinder, | |
PdfGenerator $pdfGenerator | |
) { | |
$this->accountFinder = $accountFinder; | |
$this->pdfGenerator = $pdfGenerator; | |
} | |
public function handle(Command $command): void | |
{ | |
$account = $this->accountFinder->byId($command->accountId()); | |
$accountTotal = 0; | |
foreach ($account->items as $item) { | |
$accountTotal += $item->total(); | |
} | |
$this->pdfGenerator->generate('payment-overdue-notice.template', $account, $accountTotal); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment