1 | <?php |
||
16 | class Metadata implements SimpleCollectionInterface |
||
17 | { |
||
18 | private $metadata; |
||
19 | |||
20 | |||
21 | /** |
||
22 | * @param $message |
||
23 | */ |
||
24 | function __construct($message) |
||
|
|||
25 | { |
||
26 | $this->metadata = []; |
||
27 | if (property_exists($message, 'metadata') && isset($message->metadata)) { |
||
28 | $this->metadata = (Array)$message->metadata; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | |||
33 | /** |
||
34 | * Returns an object of all the metadata keys |
||
35 | * |
||
36 | * @return stdClass |
||
37 | */ |
||
38 | public function all() |
||
42 | |||
43 | |||
44 | /** |
||
45 | * Has metadata key |
||
46 | * |
||
47 | * @param string $key |
||
48 | * |
||
49 | * @return boolean |
||
50 | */ |
||
51 | public function has($key) |
||
58 | |||
59 | |||
60 | /** |
||
61 | * Get metadata value |
||
62 | * |
||
63 | * @param string $key |
||
64 | * |
||
65 | * @return string |
||
66 | */ |
||
67 | public function get($key) |
||
74 | } |
||
75 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.