1234567891011121314151617 |
- <?php
- namespace Demo;
- use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
- class UserConverter {
- public function convert($id) {
- $id = (int) $id;
- if ($id <= 0) {
- throw new NotFoundHttpException(sprintf('User not found'));
- }
- return new User($id);
- }
- }
|