Test Failed
Push — master ( e258e4...a626ba )
by Zaahid
15:25
created

getPartForToken()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
rs 10
cc 3
nc 2
nop 2
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\IHeaderPart;
11
use ZBateson\MailMimeParser\Header\Part\MimeToken;
12
13
/**
14
 * Allows for mime-encoded parts inside a quoted part.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class QuotedStringMimeLiteralPartConsumerService extends QuotedStringConsumerService
19
{
20
    /**
21
     * Constructs a LiteralPart and returns it.
22
     *
23
     * @param bool $isLiteral not used - everything in a quoted string is a
24
     *        literal
25
     */
26
    protected function getPartForToken(string $token, bool $isLiteral) : ?IHeaderPart
27
    {
28
        if (!$isLiteral && \preg_match('/' . MimeToken::MIME_PART_PATTERN . '/', $token)) {
29
            return $this->partFactory->newMimeToken($token);
30
        }
31
        return $this->partFactory->newToken($token, $isLiteral);
32
    }
33
}
34