Skip to content

Instantly share code, notes, and snippets.

@pmjones
Last active April 26, 2017 22:18
Show Gist options
  • Save pmjones/a06e415b14fb5bf86eedaef73311bfd7 to your computer and use it in GitHub Desktop.
Save pmjones/a06e415b14fb5bf86eedaef73311bfd7 to your computer and use it in GitHub Desktop.
<?php
class DiscussionRepository
{
public function __construct(DiscussionMapper $mapper) {...}
public function fetchDiscussion($id)
{
$record = $this->mapper->select(['discussion_id' => $id])
->with(['author']);
return $this->newDiscussion($record);
}
protected function newDiscussion($record)
{
$discussionId = DiscussionId::createFrom($record->discussion_id);
$author = Author::createFrom($record->author);
return Discussion::createFrom($discussionId, $author);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment