-
-
Save maciejmiara/a01d7fd0dac3e6891c19eb3ecdc0b6e2 to your computer and use it in GitHub Desktop.
Eloquent runner repository implementation
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
<?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