Other files ignored by Codecov
CHANGELOG.md
has changed.
tests/Unit/Messaging/MessageDataTest.php
has changed.
27 | 27 | throw new InvalidArgumentException('Message data must be a one-dimensional array of string(able) keys and values.'); |
|
28 | 28 | } |
|
29 | 29 | ||
30 | + | if (self::isBinary((string) $value)) { |
|
31 | + | throw new InvalidArgumentException( |
|
32 | + | "The message data field '{$key}' seems to contain binary data. As this can lead to broken messages, " |
|
33 | + | .'please convert it to a string representation first, e.g. with bin2hex() or base64encode().' |
|
34 | + | ); |
|
35 | + | } |
|
36 | + | ||
30 | 37 | $messageData->data[(string) $key] = (string) $value; |
|
31 | 38 | } |
|
32 | 39 |
48 | 55 | { |
|
49 | 56 | return \is_null($value) || \is_scalar($value) || (\is_object($value) && \method_exists($value, '__toString')); |
|
50 | 57 | } |
|
58 | + | ||
59 | + | private static function isBinary(string $value): bool |
|
60 | + | { |
|
61 | + | return \mb_detect_encoding($value) === false; |
|
62 | + | } |
|
51 | 63 | } |
Files | Complexity | Coverage |
---|---|---|
src/Firebase | 1,376 | 67.92% |
Project Totals (146 files) | 1376 | 67.92% |