Skip to content

Commit 6fe9a39

Browse files
Simplify 'success' check
1 parent 60092e6 commit 6fe9a39

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Request.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ public function __construct(API $api) {
6161
* @throws RuntimeException on error
6262
*/
6363
protected function requireSuccessFor(array $result): int {
64-
if ((!array_key_exists('id', $result) && !array_key_exists('entry', $result)) ||
65-
(!is_numeric($result['id'] ?? 0) && !is_numeric($result['entry'] ?? 0)) ||
66-
!array_key_exists('success', $result) ||
67-
$result['success'] !== true) {
64+
$idExists = array_key_exists('id', $result) || array_key_exists('entry', $result);
65+
$idIsNumeric = is_numeric($result['id'] ?? 0) || is_numeric($result['entry'] ?? 0);
66+
$isSuccess = array_key_exists('success', $result) && $result['success'] === true;
6867

68+
if (!$idExists || !$idIsNumeric || !$isSuccess) {
6969
if (array_key_exists('message', $result)) {
7070
throw new RuntimeException(sprintf('Bad result: %s', $result['message']));
7171
} else {

0 commit comments

Comments
 (0)