1: <?php
2:
3: namespace Guzzle\Batch;
4:
5: /**
6: * Abstract decorator used when decorating a BatchInterface
7: */
8: abstract class AbstractBatchDecorator implements BatchInterface
9: {
10: /**
11: * @var BatchInterface Decorated batch object
12: */
13: protected $decoratedBatch;
14:
15: /**
16: * Create the decorator
17: *
18: * @param BatchInterface $decoratedBatch BatchInterface that is being decorated
19: */
20: public function __construct(BatchInterface $decoratedBatch)
21: {
22: $this->decoratedBatch = $decoratedBatch;
23: }
24:
25: /**
26: * Allow decorators to implement custom methods
27: *
28: * @param string $method Missing method name
29: * @param array $args Method arguments
30: *
31: * @return mixed
32: * @codeCoverageIgnore
33: */
34: public function __call($method, array $args = null)
35: {
36: return call_user_func_array(array($this->decoratedBatch, $method), $args);
37: }
38:
39: /**
40: * {@inheritdoc}
41: */
42: public function add($item)
43: {
44: $this->decoratedBatch->add($item);
45:
46: return $this;
47: }
48:
49: /**
50: * {@inheritdoc}
51: */
52: public function flush()
53: {
54: return $this->decoratedBatch->flush();
55: }
56:
57: /**
58: * {@inheritdoc}
59: */
60: public function isEmpty()
61: {
62: return $this->decoratedBatch->isEmpty();
63: }
64:
65: /**
66: * Trace the decorators associated with the batch
67: *
68: * @return array
69: */
70: public function getDecorators()
71: {
72: $found = array($this);
73: if (method_exists($this->decoratedBatch, 'getDecorators')) {
74: $found = array_merge($found, $this->decoratedBatch->getDecorators());
75: }
76:
77: return $found;
78: }
79: }
80: