Command.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace GuzzleHttp\Command;
  3. use GuzzleHttp\HandlerStack;
  4. /**
  5. * Default command implementation.
  6. */
  7. class Command implements CommandInterface
  8. {
  9. use HasDataTrait;
  10. /** @var string */
  11. private $name;
  12. /** @var HandlerStack */
  13. private $handlerStack;
  14. /**
  15. * @param string $name Name of the command
  16. * @param array $args Arguments to pass to the command
  17. * @param HandlerStack $handlerStack Stack of middleware for the command
  18. */
  19. public function __construct(
  20. $name,
  21. array $args = [],
  22. HandlerStack $handlerStack = null
  23. ) {
  24. $this->name = $name;
  25. $this->data = $args;
  26. $this->handlerStack = $handlerStack;
  27. }
  28. public function getHandlerStack()
  29. {
  30. return $this->handlerStack;
  31. }
  32. public function getName()
  33. {
  34. return $this->name;
  35. }
  36. public function hasParam($name)
  37. {
  38. return array_key_exists($name, $this->data);
  39. }
  40. public function __clone()
  41. {
  42. if ($this->handlerStack) {
  43. $this->handlerStack = clone $this->handlerStack;
  44. }
  45. }
  46. }