Last active
March 20, 2017 17:50
-
-
Save chukShirley/f907242659db0db618324468ddd445db to your computer and use it in GitHub Desktop.
Repositories
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
Class CustomerRepository | |
{ | |
private $customerTable; | |
private $customerMapper; | |
public function __construct(CustomerTable $customerTable, CustomerMapper $customerMapper) | |
{ | |
$this->customerTable = $customerTable; | |
$this->CustomerMapper = $customerMapper; | |
} | |
public function findAllPremiumCustomers() | |
{ | |
$premiumCustomers = $this->customerTable->select()->where()->etc(); | |
$collection = new PremiumCustomersCollection(); | |
foreach ($premiumCustomers as $premiumCustomer) { | |
$collection->add($this->customerMapper->hydrate(new PremiumCustomer(), $premiumCustomer)); | |
} | |
return $collection; | |
} | |
public function findAllPremiumCustomerIds() | |
{ | |
$premiumCustomers = $this->customerTable->select()->where()->etc(); | |
$collection = new PremiumCustomerIdsCollection(); | |
foreach ($premiumCustomers as $premiumCustomer) { | |
$collection->add(PremiumCustomerId::fromString($premiumCustomer['id'])); | |
} | |
return $collection; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment