| 1 |
<?php |
| 2 |
namespace Aws; |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class Command implements CommandInterface |
| 8 |
{ |
| 9 |
use HasDataTrait; |
| 10 |
|
| 11 |
|
| 12 |
private $name; |
| 13 |
|
| 14 |
|
| 15 |
private $handlerList; |
| 16 |
|
| 17 |
|
| 18 |
private $authSchemes; |
| 19 |
|
| 20 |
|
| 21 |
private $metricsBuilder; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 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 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 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 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 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 |
|
| 118 |
public function get($name) |
| 119 |
{ |
| 120 |
return $this[$name]; |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
public function getMetricsBuilder(): MetricsBuilder |
| 131 |
{ |
| 132 |
return $this->metricsBuilder; |
| 133 |
} |
| 134 |
} |