• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

azjezz / psl / 23095146612

14 Mar 2026 07:51PM UTC coverage: 98.421% (-0.06%) from 98.483%
23095146612

push

github

web-flow
feat(encoding): introduce `Psl\Encoding\EncodedWord` (#628)

111 of 119 new or added lines in 12 files covered. (93.28%)

2 existing lines in 1 file now uncovered.

9976 of 10136 relevant lines covered (98.42%)

34.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/Psl/Encoding/EncodedWord/Internal/encode_q_words.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Psl\Encoding\EncodedWord\Internal;
6

7
use function implode;
8
use function strlen;
9

10
/**
11
 * Encode text as Q-encoded words per RFC 2047.
12
 *
13
 * @internal
14
 */
15
function encode_q_words(string $text, string $prefix, string $suffix, int $maxPayload): string
16
{
17
    $words = [];
3✔
18
    $currentWord = '';
3✔
19
    $currentLen = 0;
3✔
20
    $len = strlen($text);
3✔
21

22
    for ($i = 0; $i < $len; $i++) {
3✔
23
        $byte = $text[$i];
3✔
24
        $encoded = q_encode_byte($byte);
3✔
25
        $encodedLen = strlen($encoded);
3✔
26

27
        if (($currentLen + $encodedLen) > $maxPayload && $currentWord !== '') {
3✔
NEW
28
            $words[] = $prefix . $currentWord . $suffix;
×
NEW
29
            $currentWord = '';
×
NEW
30
            $currentLen = 0;
×
31
        }
32

33
        $currentWord .= $encoded;
3✔
34
        $currentLen += $encodedLen;
3✔
35
    }
36

37
    if ($currentWord !== '') {
3✔
38
        $words[] = $prefix . $currentWord . $suffix;
3✔
39
    }
40

41
    return implode("\r\n ", $words);
3✔
42
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc