Last active
December 27, 2018 16:10
-
-
Save clslrns/d9a57e647fd8aab696d45611a5d1258a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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