PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Api / AbstractModel.php

AbstractModel.php in Media Cloud Sync 1.4.1, at includes/sdk/s3/Aws/Api/AbstractModel.php

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