Last active
January 22, 2019 19:27
-
-
Save weaver299/17a6415537529fde107435b4e425ec49 to your computer and use it in GitHub Desktop.
defensive programming
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 | |
if (empty($json_object->fields) && empty($json_object->field_deltas)) { | |
echo "Embedded Reference -- fields NO, field_deltas NO.\n"; | |
print_r($json_object); | |
die(); | |
} | |
else if (!empty($json_object->fields) && empty($json_object->field_deltas)) { | |
echo "Embedded Reference -- fields YES, field_deltas NO.\n"; | |
} | |
else if (empty($jsob_object->fields) && !empty($json_object->field_deltas)) { | |
echo "Embedded Reference -- fields YES, field_deltas NO.\n"; | |
} | |
else if (!empty($json_object->fields) && !empty($json_object->field_deltas)) { | |
echo "Embedded Reference -- fields YES, field_deltas YES -- BOTH.\n"; | |
} | |
else { | |
echo "Embedded Reference fields vs field_deltas, final else: this block should never be reached.\n"; | |
print_r($json_object); | |
die(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment