Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Command.php

raw symbols SCIP
1 <?php
2 namespace Aws;
3
4 /**
5 * AWS command object.
6 */
7 class Command implements CommandInterface
8 {
9 use HasDataTrait;
10
11 /** @var string */
12 private $name;
13
14 /** @var HandlerList */
15 private $handlerList;
16
17 /** @var array */
18 private $authSchemes;
19
20 /** @var MetricsBuilder */
21 private $metricsBuilder;
22
23 /**
24 * Accepts an associative array of command options, including:
25 *
26 * - @http: (array) Associative array of transfer options.
27 *
28 * @param string $name Name of the command
29 * @param array $args Arguments to pass to the command
30 * @param HandlerList $list Handler list
31 */
32 public function __construct(
33 $name,
34 array $args = [],
35 ?HandlerList $list = null,
36 ?MetricsBuilder $metricsBuilder = null
37 )
38 {
39 $this->name = $name;
40 $this->data = $args;
41 $this->handlerList = $list ?: new HandlerList();
42
43 if (!isset($this->data['@http'])) {
44 $this->data['@http'] = [];
45 }
46 if (!isset($this->data['@context'])) {
47 $this->data['@context'] = [];
48 }
49 $this->metricsBuilder = $metricsBuilder ?: new MetricsBuilder();
50 }
51
52 public function __clone()
53 {
54 $this->handlerList = clone $this->handlerList;
55 }
56
57 public function getName()
58 {
59 return $this->name;
60 }
61
62 public function hasParam($name)
63 {
64 return array_key_exists($name, $this->data);
65 }
66
67 public function getHandlerList()
68 {
69 return $this->handlerList;
70 }
71
72 /**
73 * For overriding auth schemes on a per endpoint basis when using
74 * EndpointV2 provider. Intended for internal use only.
75 *
76 * @param array $authSchemes
77 *
78 * @deprecated In favor of using the @context property bag.
79 * Auth Schemes are now accessible via the `signature_version` key
80 * in a Command's context, if applicable. Auth Schemes set using
81 * This method are no longer consumed.
82 *
83 * @internal
84 */
85 public function setAuthSchemes(array $authSchemes)
86 {
87 trigger_error(__METHOD__ . ' is deprecated. Auth schemes '
88 . 'resolved using the service `auth` trait or via endpoint resolution '
89 . 'are now set in the command `@context` property.`'
90 , E_USER_WARNING
91 );
92
93 $this->authSchemes = $authSchemes;
94 }
95
96 /**
97 * Get auth schemes added to command as required
98 * for endpoint resolution
99 *
100 * @returns array
101 *
102 * @deprecated In favor of using the @context property bag.
103 * Auth schemes are now accessible via the `signature_version` key
104 * in a Command's context, if applicable.
105 */
106 public function getAuthSchemes()
107 {
108 trigger_error(__METHOD__ . ' is deprecated. Auth schemes '
109 . 'resolved using the service `auth` trait or via endpoint resolution '
110 . 'can now be found in the command `@context` property.`'
111 , E_USER_WARNING
112 );
113
114 return $this->authSchemes ?: [];
115 }
116
117 /** @deprecated */
118 public function get($name)
119 {
120 return $this[$name];
121 }
122
123 /**
124 * Returns the metrics builder instance tied up to this command.
125 *
126 * @internal
127 *
128 * @return MetricsBuilder
129 */
130 public function getMetricsBuilder(): MetricsBuilder
131 {
132 return $this->metricsBuilder;
133 }
134 }