Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

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