diff options
author | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-22 11:44:41 -0400 |
---|---|---|
committer | Avi Goldman <avrahamymgoldman@gmail.com> | 2016-06-22 11:44:41 -0400 |
commit | d7f6b4b22e569ed0da339a9228f4202304fe7a05 (patch) | |
tree | 8f4da3d82e2b3eca9d60131ec768f3a5065382b9 /lib/SparkPost/SparkPostPromise.php | |
parent | 9f86fd39e85e7d3736b9b5c7ea5e95f5129773f4 (diff) | |
download | php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.zip php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.tar.gz php-sparkpost-d7f6b4b22e569ed0da339a9228f4202304fe7a05.tar.bz2 |
formatting and comments
Diffstat (limited to 'lib/SparkPost/SparkPostPromise.php')
-rw-r--r-- | lib/SparkPost/SparkPostPromise.php | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/SparkPost/SparkPostPromise.php b/lib/SparkPost/SparkPostPromise.php index 15f129f..df715d5 100644 --- a/lib/SparkPost/SparkPostPromise.php +++ b/lib/SparkPost/SparkPostPromise.php @@ -29,12 +29,14 @@ class SparkPostPromise implements HttpPromise */ public function then(callable $onFulfilled = null, callable $onRejected = null) { - return $this->promise->then(function($response) use ($onFulfilled) { - if (isset($onFulfilled)) + return $this->promise->then(function ($response) use ($onFulfilled) { + if (isset($onFulfilled)) { $onFulfilled(new SparkPostResponse($response)); - }, function($exception) use ($onRejected) { - if (isset($onRejected)) + } + }, function ($exception) use ($onRejected) { + if (isset($onRejected)) { $onRejected(new SparkPostException($exception)); + } }); } @@ -61,6 +63,7 @@ class SparkPostPromise implements HttpPromise { try { $response = $this->promise->wait($unwrap); + return $response ? new SparkPostResponse($response) : $response; } catch (\Exception $exception) { throw new SparkPostException($exception); |