Completed
Push — master ( ab502e...07a33d )
by Zaahid
06:14
created

QuotedStringConsumer::isEndToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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
namespace ZBateson\MailMimeParser\Header\Consumer;
8
9
/**
10
 * Represents a quoted part of a header value starting at a single quote, and
11
 * ending at the next single quote.
12
 * 
13
 * A quoted-pair part in a header is a literal.  There are no sub-consumers for
14
 * it and a Part\LiteralPart is returned.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class QuotedStringConsumer extends GenericConsumer
19
{
20
    /**
21
     * QuotedStringConsumer doesn't have any sub-consumers.  This method returns
22
     * an empty array.
23
     * 
24
     * @return array
25
     */
26 1
    public function getSubConsumers()
27
    {
28 1
        return [];
29
    }
30
    
31
    /**
32
     * Returns true if the token is a double quote.
33
     * 
34
     * @param string $token
35
     * @return bool
36
     */
37 1
    protected function isStartToken($token)
38
    {
39 1
        return ($token === '"');
40
    }
41
    
42
    /**
43
     * Returns true if the token is a double quote.
44
     * 
45
     * @param type $token
46
     * @return type
47
     */
48 2
    protected function isEndToken($token)
49
    {
50 2
        return ($token === '"');
51
    }
52
    
53
    /**
54
     * Returns a single regex pattern for a double quote.
55
     * 
56
     * @return string[]
57
     */
58 1
    protected function getTokenSeparators()
59
    {
60 1
        return ['\"'];
61
    }
62
    
63
    /**
64
     * Constructs a Part\LiteralPart and returns it.
65
     * 
66
     * @param string $token
67
     * @param bool $isLiteral not used - everything in a quoted string is a
68
     *        literal
69
     * @return \ZBateson\MailMimeParser\Header\Part\LiteralPart
70
     */
71 1
    protected function getPartForToken($token, $isLiteral)
72
    {
73 1
        return $this->partFactory->newLiteralPart($token);
74
    }
75
}
76