暫無描述

AsyncCallback.php 640B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace AliyunMNS;
  3. use AliyunMNS\Exception\MnsException;
  4. use AliyunMNS\Responses\BaseResponse;
  5. class AsyncCallback
  6. {
  7. protected $succeedCallback;
  8. protected $failedCallback;
  9. public function __construct(callable $succeedCallback, callable $failedCallback)
  10. {
  11. $this->succeedCallback = $succeedCallback;
  12. $this->failedCallback = $failedCallback;
  13. }
  14. public function onSucceed(BaseResponse $result)
  15. {
  16. return call_user_func($this->succeedCallback, $result);
  17. }
  18. public function onFailed(MnsException $e)
  19. {
  20. return call_user_func($this->failedCallback, $e);
  21. }
  22. }
  23. ?>