Skip to content

Commit

Permalink
feat: add Finder
Browse files Browse the repository at this point in the history
  • Loading branch information
n3wborn committed Sep 10, 2023
1 parent d7f85ea commit 72cb8e9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/Service/Project/Finder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace App\Service\Project;

use App\Entity\Project;
use App\Exception\NotFoundException;
use App\Repository\ProjectRepository;

final class Finder
{
public function __construct(
private ProjectRepository $projectRepository,
) {
}

public function get(?Project $project): ?Project
{
(null === $project)
&& throw new NotFoundException();

return
(
null !== ($result = $this->projectRepository->find($project))
)
? $result
: null;
}

public function getAll(): array
{
return $this->projectRepository->findAll();
}
}

0 comments on commit 72cb8e9

Please sign in to comment.