Skip to content

Instantly share code, notes, and snippets.

@chrisharrison
Created September 9, 2019 21:21
Show Gist options
  • Save chrisharrison/c83c26ab8ed476e25e964059c238997a to your computer and use it in GitHub Desktop.
Save chrisharrison/c83c26ab8ed476e25e964059c238997a to your computer and use it in GitHub Desktop.
<?php
final class ProduceAccountStatementHandler
{
private $accountFinder;
private $pdfGenerator;
private $accountTotalCalculator;
public function __construct(
AccountFinder $accountFinder,
PdfGenerator $pdfGenerator,
AccountTotalCalculator $accountTotalCalculator
) {
$this->accountFinder = $accountFinder;
$this->pdfGenerator = $pdfGenerator;
$this->accountTotalCalculator = $accountTotalCalculator;
}
public function handle(Command $command): void
{
$account = $this->accountFinder->byId($command->accountId());
$accountTotal = $this->accountTotalCalculator->calculate($account);
$this->pdfGenerator->generate('account-statement.template', $account, $accountTotal);
}
}
final class ProducePaymentOverdueNoticeHandler
{
private $accountFinder;
private $pdfGenerator;
private $accountTotalCalculator;
public function __construct(
AccountFinder $accountFinder,
PdfGenerator $pdfGenerator,
AccountTotalCalculator $accountTotalCalculator
) {
$this->accountFinder = $accountFinder;
$this->pdfGenerator = $pdfGenerator;
$this->accountTotalCalculator = $accountTotalCalculator;
}
public function handle(Command $command): void
{
$account = $this->accountFinder->byId($command->accountId());
$accountTotal = $this->accountTotalCalculator->calculate($account);
$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