1: <?php
2:
3: namespace Guzzle\Batch\Exception;
4:
5: use Guzzle\Common\Exception\GuzzleException;
6: use Guzzle\Batch\BatchTransferInterface as TransferStrategy;
7: use Guzzle\Batch\BatchDivisorInterface as DivisorStrategy;
8:
9: /**
10: * Exception thrown during a batch transfer
11: */
12: class BatchTransferException extends \Exception implements GuzzleException
13: {
14: /**
15: * @var array The batch being sent when the exception occurred
16: */
17: protected $batch;
18:
19: /**
20: * @var TransferStrategy The transfer strategy in use when the exception occurred
21: */
22: protected $transferStrategy;
23:
24: /**
25: * @var DivisorStrategy The divisor strategy in use when the exception occurred
26: */
27: protected $divisorStrategy;
28:
29: /**
30: * @var array Items transferred at the point in which the exception was encountered
31: */
32: protected $transferredItems;
33:
34: /**
35: * @param array $batch The batch being sent when the exception occurred
36: * @param array $transferredItems Items transferred at the point in which the exception was encountered
37: * @param \Exception $exception Exception encountered
38: * @param TransferStrategy $transferStrategy The transfer strategy in use when the exception occurred
39: * @param DivisorStrategy $divisorStrategy The divisor strategy in use when the exception occurred
40: */
41: public function __construct(
42: array $batch,
43: array $transferredItems,
44: \Exception $exception,
45: TransferStrategy $transferStrategy = null,
46: DivisorStrategy $divisorStrategy = null
47: ) {
48: $this->batch = $batch;
49: $this->transferredItems = $transferredItems;
50: $this->transferStrategy = $transferStrategy;
51: $this->divisorStrategy = $divisorStrategy;
52: parent::__construct(
53: 'Exception encountered while transferring batch: ' . $exception->getMessage(),
54: $exception->getCode(),
55: $exception
56: );
57: }
58:
59: /**
60: * Get the batch that we being sent when the exception occurred
61: *
62: * @return array
63: */
64: public function getBatch()
65: {
66: return $this->batch;
67: }
68:
69: /**
70: * Get the items transferred at the point in which the exception was encountered
71: *
72: * @return array
73: */
74: public function getTransferredItems()
75: {
76: return $this->transferredItems;
77: }
78:
79: /**
80: * Get the transfer strategy
81: *
82: * @return TransferStrategy
83: */
84: public function getTransferStrategy()
85: {
86: return $this->transferStrategy;
87: }
88:
89: /**
90: * Get the divisor strategy
91: *
92: * @return DivisorStrategy
93: */
94: public function getDivisorStrategy()
95: {
96: return $this->divisorStrategy;
97: }
98: }
99: