| 1 |
<?php |
| 2 |
|
| 3 |
namespace Dudlewebs\WPMCS\s3\Aws; |
| 4 |
|
| 5 |
use Dudlewebs\WPMCS\s3\JmesPath\Env as JmesPath; |
| 6 |
/** |
| 7 |
* AWS result. |
| 8 |
*/ |
| 9 |
class Result implements ResultInterface, MonitoringEventsInterface |
| 10 |
{ |
| 11 |
use HasDataTrait; |
| 12 |
use HasMonitoringEventsTrait; |
| 13 |
public function __construct(array $data = []) |
| 14 |
{ |
| 15 |
$this->data = $data; |
| 16 |
} |
| 17 |
public function hasKey($name) |
| 18 |
{ |
| 19 |
return isset($this->data[$name]); |
| 20 |
} |
| 21 |
public function get($key) |
| 22 |
{ |
| 23 |
return $this[$key]; |
| 24 |
} |
| 25 |
public function search($expression) |
| 26 |
{ |
| 27 |
return JmesPath::search($expression, $this->toArray()); |
| 28 |
} |
| 29 |
public function __toString() |
| 30 |
{ |
| 31 |
$jsonData = \json_encode($this->toArray(), \JSON_PRETTY_PRINT); |
| 32 |
return <<<EOT |
| 33 |
Model Data |
| 34 |
---------- |
| 35 |
Data can be retrieved from the model object using the get() method of the |
| 36 |
model (e.g., `\$result->get(\$key)`) or "accessing the result like an |
| 37 |
associative array (e.g. `\$result['key']`). You can also execute JMESPath |
| 38 |
expressions on the result data using the search() method. |
| 39 |
|
| 40 |
{$jsonData} |
| 41 |
|
| 42 |
EOT; |
| 43 |
} |
| 44 |
/** |
| 45 |
* @deprecated |
| 46 |
*/ |
| 47 |
public function getPath($path) |
| 48 |
{ |
| 49 |
return $this->search(\str_replace('/', '.', $path)); |
| 50 |
} |
| 51 |
} |
| 52 |
|