QuotedStringMimeLiteralPartTokenSplitPatternTrait   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getTokenSplitPattern() 0 5 1
1
<?php
2
/**
3
 * This file is part of the ZBateson\MailMimeParser project.
4
 *
5
 * @license http://opensource.org/licenses/bsd-license.php BSD
6
 */
7
8
namespace ZBateson\MailMimeParser\Header\Consumer;
9
10
use ZBateson\MailMimeParser\Header\Part\MimeToken;
11
12
/**
13
 * Provides a getTokenSplitPattern for consumers that could have quoted parts
14
 * that are mime-header-encoded.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
trait QuotedStringMimeLiteralPartTokenSplitPatternTrait
19
{
20
    /**
21
     * Overridden to use a specialized regex for finding mime-encoded parts
22
     * (RFC 2047).
23
     *
24
     * Some implementations seem to place mime-encoded parts within quoted
25
     * parameters, and split the mime-encoded parts across multiple split
26
     * parameters.  The specialized regex doesn't allow double quotes inside a
27
     * mime encoded part, so it can be "continued" in another parameter.
28
     *
29
     * @return string the regex pattern
30
     */
31 20
    protected function getTokenSplitPattern() : string
32
    {
33 20
        $sChars = \implode('|', $this->getAllTokenSeparators());
0 ignored issues
show
Bug introduced by
It seems like getAllTokenSeparators() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
        $sChars = \implode('|', $this->/** @scrutinizer ignore-call */ getAllTokenSeparators());
Loading history...
34 20
        $mimePartPattern = MimeToken::MIME_PART_PATTERN_NO_QUOTES;
35 20
        return '~(' . $mimePartPattern . '|\\\\\r\n|\\\\.|' . $sChars . ')~ms';
36
    }
37
}
38