UserConverter.php 293 B

1234567891011121314151617
  1. <?php
  2. namespace Demo;
  3. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  4. class UserConverter {
  5. public function convert($id) {
  6. $id = (int) $id;
  7. if ($id <= 0) {
  8. throw new NotFoundHttpException(sprintf('User not found'));
  9. }
  10. return new User($id);
  11. }
  12. }