Skip to content

Instantly share code, notes, and snippets.

@icambridge
Created November 1, 2014 22:55
Show Gist options
  • Save icambridge/32fc27ce96fc88eb2a7d to your computer and use it in GitHub Desktop.
Save icambridge/32fc27ce96fc88eb2a7d to your computer and use it in GitHub Desktop.
returning null compared to throwing an exception
<?php
$person = $peopleRepo->getLatest();
if (null === $person) {
$log->warn('No person found');
}
$person->inviteToParty();
// becomes
try {
$people->getLatest()->inviteToParty();
} catch (NoPersoFound $e) {
$logger->warn('No person found');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment