Skip to content

Instantly share code, notes, and snippets.

@Vilintritenmert
Created December 10, 2020 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vilintritenmert/a6bb2cb956f5f32923c5d50e9e16e3fd to your computer and use it in GitHub Desktop.
Save Vilintritenmert/a6bb2cb956f5f32923c5d50e9e16e3fd to your computer and use it in GitHub Desktop.
Domain Driven Design
<?php
class Register {
/**
* @param $repository CustomerRepositoryInterface
* @param $history CustomerHistoryInterface
**/
public function __constructor(
CustomerRepositoryInterface $repository,
CustomerHistoryInterface $history
) {
$this->repository = $repository;
$this->history = $history;
}
/**
* @param $customerDTO CustomerDTO
*
* @return Customer
**/
public function handle(CustomerDTO $customerDTO): Customer
{
$customer = $this->repository->create($customerDTO);
$this->history->registered($customer);
return $customer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment