1: <?php
2:
3: namespace Guzzle\Service\Command;
4:
5: use Guzzle\Common\Exception\InvalidArgumentException;
6: use Guzzle\Common\Exception\UnexpectedValueException;
7: use Guzzle\Http\Message\RequestInterface;
8:
9: 10: 11: 12: 13:
14: class ClosureCommand extends AbstractCommand
15: {
16: 17: 18: 19:
20: protected function init()
21: {
22: if (!$this->get('closure')) {
23: throw new InvalidArgumentException('A closure must be passed in the parameters array');
24: }
25: }
26:
27: 28: 29: 30:
31: protected function build()
32: {
33: $closure = $this->get('closure');
34:
35: $this->request = $closure($this, $this->operation);
36:
37: if (!$this->request || !$this->request instanceof RequestInterface) {
38: throw new UnexpectedValueException('Closure command did not return a RequestInterface object');
39: }
40: }
41: }
42: