1 | <?php |
||
26 | class GenericMessage implements |
||
27 | \PEIP\INF\Message\Message, |
||
28 | \PEIP\INF\Base\Buildable |
||
29 | { |
||
30 | const CONTENT_CAST_TYPE = ''; |
||
31 | |||
32 | private $content, |
||
33 | $headers; |
||
34 | |||
35 | /** |
||
36 | * constructor. |
||
37 | * |
||
38 | * @param mixed $content The content/payload of the message |
||
39 | * @param array|ArrayAccess $headers headers as key/value pairs |
||
40 | */ |
||
41 | public function __construct($content, $headers = []) |
||
46 | |||
47 | /** |
||
48 | * Returns the content of the container. |
||
49 | * |
||
50 | * @implements \PEIP\INF\Base\Container |
||
51 | * |
||
52 | * @return |
||
53 | */ |
||
54 | public function getContent() |
||
58 | |||
59 | /** |
||
60 | * sets content/payload of message - to be overwritten by derived classes. |
||
61 | * |
||
62 | * @param mixed $content The content/payload of the message |
||
63 | */ |
||
64 | protected function doSetContent($content) |
||
68 | |||
69 | protected function doSetHeaders($headers) |
||
77 | |||
78 | /** |
||
79 | * returns all headers of the message. |
||
80 | * |
||
81 | * @return ArrayAccess ArrayAccess object of headers |
||
82 | */ |
||
83 | public function getHeaders() |
||
87 | |||
88 | /** |
||
89 | * returns one specific header of the message. |
||
90 | * |
||
91 | * @param string $name the name of the header |
||
92 | * |
||
93 | * @return mixed the value of the header |
||
94 | */ |
||
95 | public function getHeader($name) |
||
101 | |||
102 | /** |
||
103 | * adds a specific header to the message if that header |
||
104 | * has not allready been set. |
||
105 | * |
||
106 | * @param string $name the name of the header |
||
107 | * |
||
108 | * @return bool wether the header has been successfully set |
||
109 | */ |
||
110 | public function addHeader($name, $value) |
||
120 | |||
121 | /** |
||
122 | * checks wether a specific header is set on the message. |
||
123 | * |
||
124 | * @param string $name the name of the header |
||
125 | * |
||
126 | * @return bool wether the header is set |
||
127 | */ |
||
128 | public function hasHeader($name) |
||
132 | |||
133 | /** |
||
134 | * returns content/payload of the message as string representation for the instance. |
||
135 | * |
||
136 | * @return string content/payload of the message |
||
137 | */ |
||
138 | public function __toString() |
||
153 | |||
154 | /** |
||
155 | * Provides a static build method to create new Instances of this class. |
||
156 | * Implements \PEIP\INF\Base\Buildable. |
||
157 | * |
||
158 | * @static |
||
159 | * @implements \PEIP\INF\Base\Buildable |
||
160 | * |
||
161 | * @param array $arguments argumends for the constructor |
||
162 | * |
||
163 | * @return GenericMessage new class instance |
||
164 | */ |
||
165 | public static function build(array $arguments = []) |
||
169 | } |
||
170 |