| 1 | <?php |
||
| 9 | class Raw implements WritableMessage |
||
| 10 | { |
||
| 11 | protected |
||
| 12 | $body; |
||
|
1 ignored issue
–
show
|
|||
| 13 | |||
| 14 | private |
||
| 15 | $flags, |
||
|
1 ignored issue
–
show
|
|||
| 16 | $headers, |
||
| 17 | $attributes; |
||
| 18 | |||
| 19 | 23 | public function __construct($routingKey = '') |
|
| 27 | |||
| 28 | 23 | private function initializeAttributes() |
|
| 53 | |||
| 54 | 14 | public function getContentType() |
|
| 58 | |||
| 59 | 11 | public function getRoutingKey() |
|
| 63 | |||
| 64 | 4 | public function getFormattedBody() |
|
| 68 | |||
| 69 | 2 | protected function formatBody() |
|
| 70 | { |
||
| 71 | 2 | return implode("\n", $this->body); |
|
| 72 | } |
||
| 73 | |||
| 74 | 6 | public function setBody($body) |
|
| 75 | { |
||
| 76 | 6 | if(! is_array($body)) |
|
| 77 | 6 | { |
|
| 78 | 3 | $body = array($body); |
|
| 79 | 3 | } |
|
| 80 | |||
| 81 | 6 | $this->body = $body; |
|
| 82 | |||
| 83 | 6 | return $this; |
|
| 84 | } |
||
| 85 | |||
| 86 | public function getFlags() |
||
| 90 | |||
| 91 | public function setFlags($flags) |
||
| 97 | |||
| 98 | 5 | public function addHeader($headerName, $value) |
|
| 104 | |||
| 105 | 3 | public function addHeaders(array $headers) |
|
| 106 | { |
||
| 107 | 3 | foreach($headers as $name => $value) |
|
| 108 | { |
||
| 109 | 3 | $this->addHeader($name, $value); |
|
| 110 | 3 | } |
|
| 111 | |||
| 112 | 3 | return $this; |
|
| 113 | } |
||
| 114 | |||
| 115 | 3 | public function setAuthor($author) |
|
| 116 | { |
||
| 117 | 3 | $this->addHeader('author', $author); |
|
| 118 | |||
| 119 | 3 | return $this; |
|
| 120 | } |
||
| 121 | |||
| 122 | 11 | public function packAttributes($timestamp = false) |
|
| 140 | |||
| 141 | 11 | private function packHeaders($timestamp) |
|
| 147 | |||
| 148 | 23 | public function setAttribute($attributeName, $value) |
|
| 160 | |||
| 161 | public function getAppId() |
||
| 165 | |||
| 166 | 4 | public function getHeaders() |
|
| 167 | { |
||
| 168 | 4 | $attributes = $this->packAttributes(); |
|
| 169 | |||
| 170 | 4 | return $attributes['headers']; |
|
| 171 | } |
||
| 172 | |||
| 173 | 13 | public function getAttribute($attributeName) |
|
| 174 | { |
||
| 175 | 13 | if(array_key_exists($attributeName, $this->attributes)) |
|
| 176 | 13 | { |
|
| 177 | 12 | return $this->attributes[$attributeName]; |
|
| 178 | } |
||
| 179 | |||
| 180 | 1 | throw new InvalidArgumentException(sprintf('Property "%s" is unknown or is not a message property', $attributeName)); |
|
| 181 | } |
||
| 182 | |||
| 183 | public function __toString() |
||
| 192 | |||
| 193 | 1 | public function setExpiration($expirationInSeconds) |
|
| 194 | { |
||
| 195 | 1 | $ttlInMs = 1000 * (int) $expirationInSeconds; |
|
| 196 | |||
| 197 | 1 | $this->setAttribute('expiration', (string) $ttlInMs); |
|
| 198 | |||
| 201 | |||
| 202 | 2 | public static function buildFromReadableMessage(ReadableMessage $readableMessage, $newRoutingKey = false) |
|
| 235 | } |
||
| 236 |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.