PluginProbe
Media Cloud Sync / 1.0.1
Media Cloud Sync v1.0.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.0.1, at includes/sdk/s3/Aws/Api/AbstractModel.php

71 lines 1.7 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 /**
15 * @param array $definition Service description
16 * @param ShapeMap $shapeMap Shapemap used for creating shapes
17 */
18 public function __construct(array $definition, ShapeMap $shapeMap)
19 {
20 $this->definition = $definition;
21 $this->shapeMap = $shapeMap;
22 }
23 public function toArray()
24 {
25 return $this->definition;
26 }
27 /**
28 * @return mixed|null
29 */
30 #[\ReturnTypeWillChange]
31 public function offsetGet($offset)
32 {
33 return isset($this->definition[$offset]) ? $this->definition[$offset] : null;
34 }
35 /**
36 * @return void
37 */
38 #[\ReturnTypeWillChange]
39 public function offsetSet($offset, $value)
40 {
41 $this->definition[$offset] = $value;
42 }
43 /**
44 * @return bool
45 */
46 #[\ReturnTypeWillChange]
47 public function offsetExists($offset)
48 {
49 return isset($this->definition[$offset]);
50 }
51 /**
52 * @return void
53 */
54 #[\ReturnTypeWillChange]
55 public function offsetUnset($offset)
56 {
57 unset($this->definition[$offset]);
58 }
59 protected function shapeAt($key)
60 {
61 if (!isset($this->definition[$key])) {
62 throw new \InvalidArgumentException('Expected shape definition at ' . $key);
63 }
64 return $this->shapeFor($this->definition[$key]);
65 }
66 protected function shapeFor(array $definition)
67 {
68 return isset($definition['shape']) ? $this->shapeMap->resolve($definition) : Shape::create($definition, $this->shapeMap);
69 }
70 }
71