Passed
Push — master ( b864c0...663ed6 )
by Zaahid
14:05
created

ParameterValueConsumerService::processParts()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
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
8
namespace ZBateson\MailMimeParser\Header\Consumer;
9
10
use Psr\Log\LoggerInterface;
11
use ZBateson\MailMimeParser\Header\Part\MimeTokenPartFactory;
12
13
/**
14
 * Starts processing tokens after a '=' character is found, indicating the
15
 * 'value' portion of a name/value pair in a parameter header.
16
 *
17
 * The value portion will consist of all tokens, quoted parts, and comment parts
18
 * parsed up to a semi-colon token indicating control should be returned to the
19
 * parent ParameterNameValueConsumerService.
20
 *
21
 * @author Zaahid Bateson
22
 */
23
class ParameterValueConsumerService extends GenericConsumerMimeLiteralPartService
24
{
25 7
    public function __construct(
26
        LoggerInterface $logger,
27
        MimeTokenPartFactory $partFactory,
28
        CommentConsumerService $commentConsumerService,
29
        QuotedStringMimeLiteralPartConsumerService $quotedStringConsumerService
30
    ) {
31 7
        parent::__construct(
32 7
            $logger,
33 7
            $partFactory,
34 7
            $commentConsumerService,
35 7
            $quotedStringConsumerService
36 7
        );
37
    }
38
39
    /**
40
     * Returns semi-colon and equals char as token separators.
41
     *
42
     * @return string[]
43
     */
44 8
    protected function getTokenSeparators() : array
45
    {
46 8
        return \array_merge(parent::getTokenSeparators(), ['=', ';']);
47
    }
48
49
    /**
50
     * Returns true if the token is an '=' character.
51
     */
52 103
    protected function isStartToken(string $token) : bool
53
    {
54 103
        return ($token === '=');
55
    }
56
57
    /**
58
     * Returns true if the token is a ';' character.
59
     */
60 108
    protected function isEndToken(string $token) : bool
61
    {
62 108
        return ($token === ';');
63
    }
64
}
65