Skip to content

Instantly share code, notes, and snippets.

@clslrns
Last active December 27, 2018 16:10
Show Gist options
  • Save clslrns/d9a57e647fd8aab696d45611a5d1258a to your computer and use it in GitHub Desktop.
Save clslrns/d9a57e647fd8aab696d45611a5d1258a to your computer and use it in GitHub Desktop.
<?php
interface Job
{
/**
* @throws JobException
*/
public function do(): void;
}
class Job1 implements Job
{
public function do(): void
{
$user = $this->repo->get(1);
if ($user === null) {
throw new JobException('No user provided');
}
// actual job
}
}
class Job2 implements Job
{
public function do(): void
{
try {
$user = $this->repo->get(1);
} catch (UserNotFoundException $e) {
throw new JobException('No user provided');
}
// actual job
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment