Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Api/AbstractModel.php

raw symbols SCIP
1 <?php
2 namespace Aws\Api;
3
4 /**
5 * Base class that is used by most API shapes
6 */
7 abstract class AbstractModel implements \ArrayAccess
8 {
9 /** @var array */
10 protected $definition;
11
12 /** @var ShapeMap */
13 protected $shapeMap;
14
15 /** @var array */
16 protected $contextParam;
17
18 /**
19 * @param array $definition Service description
20 * @param ShapeMap $shapeMap Shapemap used for creating shapes
21 */
22 public function __construct(array $definition, ShapeMap $shapeMap)
23 {
24 $this->definition = $definition;
25 $this->shapeMap = $shapeMap;
26 if (isset($definition['contextParam'])) {
27 $this->contextParam = $definition['contextParam'];
28 }
29 }
30
31 public function toArray()
32 {
33 return $this->definition;
34 }
35
36 /**
37 * @return mixed|null
38 */
39 #[\ReturnTypeWillChange]
40 public function offsetGet($offset)
41 {
42 return isset($this->definition[$offset])
43 ? $this->definition[$offset] : null;
44 }
45
46 /**
47 * @return void
48 */
49 #[\ReturnTypeWillChange]
50 public function offsetSet($offset, $value)
51 {
52 $this->definition[$offset] = $value;
53 }
54
55 /**
56 * @return bool
57 */
58 #[\ReturnTypeWillChange]
59 public function offsetExists($offset)
60 {
61 return isset($this->definition[$offset]);
62 }
63
64 /**
65 * @return void
66 */
67 #[\ReturnTypeWillChange]
68 public function offsetUnset($offset)
69 {
70 unset($this->definition[$offset]);
71 }
72
73 protected function shapeAt($key)
74 {
75 if (!isset($this->definition[$key])) {
76 throw new \InvalidArgumentException('Expected shape definition at '
77 . $key);
78 }
79
80 return $this->shapeFor($this->definition[$key]);
81 }
82
83 protected function shapeFor(array $definition)
84 {
85 return isset($definition['shape'])
86 ? $this->shapeMap->resolve($definition)
87 : Shape::create($definition, $this->shapeMap);
88 }
89 }