1: <?php
2:
3: namespace Guzzle\Http\Exception;
4:
5: use Guzzle\Common\Exception\ExceptionCollection;
6: use Guzzle\Http\Message\RequestInterface;
7:
8: /**
9: * Exception encountered during a multi transfer
10: */
11: class MultiTransferException extends ExceptionCollection
12: {
13: protected $successfulRequests = array();
14: protected $failedRequests = array();
15:
16: /**
17: * Get all of the requests in the transfer
18: *
19: * @return array
20: */
21: public function getAllRequests()
22: {
23: return array_merge($this->successfulRequests, $this->failedRequests);
24: }
25:
26: /**
27: * Add to the array of successful requests
28: *
29: * @param RequestInterface $request Successful request
30: *
31: * @return self
32: */
33: public function addSuccessfulRequest(RequestInterface $request)
34: {
35: $this->successfulRequests[] = $request;
36:
37: return $this;
38: }
39:
40: /**
41: * Add to the array of failed requests
42: *
43: * @param RequestInterface $request Failed request
44: *
45: * @return self
46: */
47: public function addFailedRequest(RequestInterface $request)
48: {
49: $this->failedRequests[] = $request;
50:
51: return $this;
52: }
53:
54: /**
55: * Set all of the successful requests
56: *
57: * @param array Array of requests
58: *
59: * @return self
60: */
61: public function setSuccessfulRequests(array $requests)
62: {
63: $this->successfulRequests = $requests;
64:
65: return $this;
66: }
67:
68: /**
69: * Set all of the failed requests
70: *
71: * @param array Array of requests
72: *
73: * @return self
74: */
75: public function setFailedRequests(array $requests)
76: {
77: $this->failedRequests = $requests;
78:
79: return $this;
80: }
81:
82: /**
83: * Get an array of successful requests sent in the multi transfer
84: *
85: * @return array
86: */
87: public function getSuccessfulRequests()
88: {
89: return $this->successfulRequests;
90: }
91:
92: /**
93: * Get an array of failed requests sent in the multi transfer
94: *
95: * @return array
96: */
97: public function getFailedRequests()
98: {
99: return $this->failedRequests;
100: }
101:
102: /**
103: * Check if the exception object contains a request
104: *
105: * @param RequestInterface $request Request to check
106: *
107: * @return bool
108: */
109: public function containsRequest(RequestInterface $request)
110: {
111: return in_array($request, $this->failedRequests, true) || in_array($request, $this->successfulRequests, true);
112: }
113: }
114: