/RunnerRepository.php Secret
Created
March 11, 2019 09:50
-
-
Save tsh-code/e593e684f504ebd07bfc5bbab8ca4b2d 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