Skip to content

Instantly share code, notes, and snippets.

@maciejmiara
Created February 25, 2019 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save maciejmiara/a01d7fd0dac3e6891c19eb3ecdc0b6e2 to your computer and use it in GitHub Desktop.
Save maciejmiara/a01d7fd0dac3e6891c19eb3ecdc0b6e2 to your computer and use it in GitHub Desktop.
Eloquent runner repository implementation
<?php
declare(strict_types = 1);
namespace Infrastructure\Eloquent\Repository;
use Common\Id;
use Domain\Exception\RunnerNotFound;
use Domain\Model\Runner;
use Infrastructure\Eloquent\Transformer\RunnerTransformer;
class RunnerRepository implements \Domain\Repository\RunnerRepository
{
private $runnerTransformer;
public function __construct(RunnerTransformer $runnerTransformer)
{
$this->runnerTransformer = $runnerTransformer;
}
/**
* {@inheritdoc}
*/
public function getById(Id $runnerId): Runner
{
$runner = \Infrastructure\Eloquent\Model\Runner::find((string)$runnerId);
if (null === $runner) {
throw RunnerNotFound::forId($runnerId);
}
return $this->runnerTransformer->entityToDomain($runner);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment