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

QuotedStringMimeLiteralPartConsumerService   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 4
c 1
b 0
f 0
dl 0
loc 14
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPartForToken() 0 6 3
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