1 | <?php |
||
25 | class MessageBuilder implements |
||
26 | \PEIP\INF\Message\MessageBuilder, |
||
27 | \PEIP\INF\Factory\DedicatedFactory |
||
28 | { |
||
29 | protected $messageClass, |
||
30 | $factory, |
||
31 | $headers = [], |
||
32 | $payload; |
||
33 | |||
34 | /** |
||
35 | * constructor. |
||
36 | * |
||
37 | * @param string $messageClass the message-class to build instances for |
||
38 | */ |
||
39 | public function __construct($messageClass = '\PEIP\Message\GenericMessage') |
||
44 | |||
45 | /** |
||
46 | * copies headers to message to build. |
||
47 | * |
||
48 | * @param array $headers the headers to set |
||
49 | * |
||
50 | * @return MessageBuilder $this |
||
51 | */ |
||
52 | public function copyHeaders(array $headers) |
||
58 | |||
59 | /** |
||
60 | * copies headers to message to build if not set allerady. |
||
61 | * |
||
62 | * @param array $headers the headers to set |
||
63 | * |
||
64 | * @return MessageBuilder $this |
||
65 | */ |
||
66 | public function copyHeadersIfAbsent(array $headers) |
||
72 | |||
73 | /** |
||
74 | * removes a header from message to build. |
||
75 | * |
||
76 | * @param string $headerName the name of the header |
||
77 | * |
||
78 | * @return MessageBuilder $this |
||
79 | */ |
||
80 | public function removeHeader($headerName) |
||
86 | |||
87 | /** |
||
88 | * sets a header for the message to build. |
||
89 | * |
||
90 | * @param string $headerName the name of the header |
||
91 | * @param mixed $headerValue the value for the header |
||
92 | * |
||
93 | * @return MessageBuilder $this |
||
94 | */ |
||
95 | public function setHeader($headerName, $headerValue) |
||
101 | |||
102 | /** |
||
103 | * sets all headers for the message to build. |
||
104 | * |
||
105 | * @param array $headers the headers to set |
||
106 | * |
||
107 | * @return MessageBuilder $this |
||
108 | */ |
||
109 | public function setHeaders(array $headers) |
||
115 | |||
116 | /** |
||
117 | * returns the headers for the message to build. |
||
118 | * |
||
119 | * @return array the headers for the message to build |
||
120 | */ |
||
121 | public function getHeaders() |
||
125 | |||
126 | /** |
||
127 | * creates a new message instance with given headers. |
||
128 | * |
||
129 | * @param $arguments |
||
130 | * |
||
131 | * @return |
||
132 | */ |
||
133 | public function build(array $headers = []) |
||
140 | |||
141 | /** |
||
142 | * sets the content/payload for the message to build. |
||
143 | * |
||
144 | * @param mixed $payload payload for the message to build |
||
145 | * |
||
146 | * @return MessageBuilder $this |
||
147 | */ |
||
148 | public function setContent($payload) |
||
154 | |||
155 | /** |
||
156 | * returns a instance of MessageBuilder for given message-class. |
||
157 | * |
||
158 | * @static |
||
159 | * |
||
160 | * @param string $messageClass the message class to build from the builder |
||
161 | * |
||
162 | * @return MessageBuilder new instance of MessageBuilder |
||
163 | */ |
||
164 | public static function getInstance($messageClass = '\PEIP\Message\GenericMessage') |
||
168 | |||
169 | /** |
||
170 | * returns a instance of MessageBuilder for message-class derived from given message. |
||
171 | * |
||
172 | * @static |
||
173 | * |
||
174 | * @param \PEIP\INF\Message\Message $message the message to get class to build from the builder |
||
175 | * |
||
176 | * @return MessageBuilder new instance of MessageBuilder |
||
177 | */ |
||
178 | public static function getInstanceFromMessage(\PEIP\INF\Message\Message $message) |
||
182 | |||
183 | /** |
||
184 | * sets the message-class to build new instances for. |
||
185 | * |
||
186 | * @param string $messageClass the message-class to build new instances for |
||
187 | */ |
||
188 | public function setMessageClass($messageClass) |
||
192 | |||
193 | /** |
||
194 | * returns the message-class to build new instances for. |
||
195 | * |
||
196 | * @return string the message-class to build new instances for |
||
197 | */ |
||
198 | public function getMessageClass() |
||
202 | } |
||
203 |