Command.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace Aws;
  3. /**
  4. * AWS command object.
  5. */
  6. class Command implements CommandInterface
  7. {
  8. use HasDataTrait;
  9. /** @var string */
  10. private $name;
  11. /** @var HandlerList */
  12. private $handlerList;
  13. /**
  14. * Accepts an associative array of command options, including:
  15. *
  16. * - @http: (array) Associative array of transfer options.
  17. *
  18. * @param string $name Name of the command
  19. * @param array $args Arguments to pass to the command
  20. * @param HandlerList $list Handler list
  21. */
  22. public function __construct($name, array $args = [], HandlerList $list = null)
  23. {
  24. $this->name = $name;
  25. $this->data = $args;
  26. $this->handlerList = $list ?: new HandlerList();
  27. if (!isset($this->data['@http'])) {
  28. $this->data['@http'] = [];
  29. }
  30. if (!isset($this->data['@context'])) {
  31. $this->data['@context'] = [];
  32. }
  33. }
  34. public function __clone()
  35. {
  36. $this->handlerList = clone $this->handlerList;
  37. }
  38. public function getName()
  39. {
  40. return $this->name;
  41. }
  42. public function hasParam($name)
  43. {
  44. return array_key_exists($name, $this->data);
  45. }
  46. public function getHandlerList()
  47. {
  48. return $this->handlerList;
  49. }
  50. /** @deprecated */
  51. public function get($name)
  52. {
  53. return $this[$name];
  54. }
  55. }