Last active
October 28, 2016 07:15
-
-
Save am-/427f3ccf77bc542526538d91f953e1b0 to your computer and use it in GitHub Desktop.
This file contains 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 | |
function computationWithAssumedKeys(array $array, array $necessaryKeys) { | |
$missingKeys = array_diff($necessaryKeys, array_keys($array)); | |
if (!empty($missingKeys)) { | |
$message = 'Computation failed due to missing key(s): ' . implode(', ', $missingKeys); | |
throw new \RuntimeException($message); | |
} | |
// compute... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment