| 1 |
<?php |
| 2 |
namespace Aws\Api; |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class StructureShape extends Shape |
| 8 |
{ |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
private $members; |
| 13 |
|
| 14 |
public function __construct(array $definition, ShapeMap $shapeMap) |
| 15 |
{ |
| 16 |
$definition['type'] = 'structure'; |
| 17 |
|
| 18 |
if (!isset($definition['members'])) { |
| 19 |
$definition['members'] = []; |
| 20 |
} |
| 21 |
|
| 22 |
parent::__construct($definition, $shapeMap); |
| 23 |
} |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
public function getMembers() |
| 31 |
{ |
| 32 |
if (empty($this->members)) { |
| 33 |
$this->generateMembersHash(); |
| 34 |
} |
| 35 |
|
| 36 |
return $this->members; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public function hasMember($name) |
| 47 |
{ |
| 48 |
return isset($this->definition['members'][$name]); |
| 49 |
} |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
public function getMember($name) |
| 60 |
{ |
| 61 |
$members = $this->getMembers(); |
| 62 |
|
| 63 |
if (!isset($members[$name])) { |
| 64 |
throw new \InvalidArgumentException('Unknown member ' . $name); |
| 65 |
} |
| 66 |
|
| 67 |
return $members[$name]; |
| 68 |
} |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
public function getShapeMap(): ShapeMap |
| 81 |
{ |
| 82 |
return $this->shapeMap; |
| 83 |
} |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public function getOriginalDefinition(string $name): ?array |
| 93 |
{ |
| 94 |
return $this->shapeMap[$name] ?? null; |
| 95 |
} |
| 96 |
|
| 97 |
private function generateMembersHash() |
| 98 |
{ |
| 99 |
$this->members = []; |
| 100 |
|
| 101 |
foreach ($this->definition['members'] as $name => $definition) { |
| 102 |
$this->members[$name] = $this->shapeFor($definition); |
| 103 |
} |
| 104 |
} |
| 105 |
} |