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

ParameterValueConsumerService   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
eloc 10
c 2
b 0
f 0
dl 0
loc 52
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A isEndToken() 0 3 1
A isStartToken() 0 3 1
A getTokenSeparators() 0 3 1
A processParts() 0 3 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\IHeaderPart;
12
use ZBateson\MailMimeParser\Header\Part\MimeTokenPartFactory;
13
14
/**
15
 * @author Zaahid Bateson
16
 */
17
class ParameterValueConsumerService extends GenericConsumerMimeLiteralPartService
18
{
19
    public function __construct(
20
        LoggerInterface $logger,
21
        MimeTokenPartFactory $partFactory,
22
        CommentConsumerService $commentConsumerService,
23
        QuotedStringMimeLiteralPartConsumerService $quotedStringConsumerService
24
    ) {
25
        parent::__construct(
26
            $logger,
27
            $partFactory,
28
            $commentConsumerService,
29
            $quotedStringConsumerService
30
        );
31
    }
32
33
    /**
34
     * Returns semi-colon and equals char as token separators.
35
     *
36
     * @return string[]
37
     */
38
    protected function getTokenSeparators() : array
39
    {
40
        return \array_merge(parent::getTokenSeparators(), ['=']);
41
    }
42
    
43
    /**
44
     * Returns true if the token is an '=' character.
45
     */
46
    protected function isStartToken(string $token) : bool
47
    {
48
        return ($token === '=');
49
    }
50
51
    /**
52
     * Returns true if the token is a ';' character.
53
     */
54
    protected function isEndToken(string $token) : bool
55
    {
56
        return ($token === ';');
57
    }
58
59
    /**
60
     * Post processing involves creating Part\LiteralPart or Part\ParameterPart
61
     * objects out of created Token and LiteralParts.
62
     *
63
     * @param IHeaderPart[] $parts The parsed parts.
64
     * @return IHeaderPart[] Array of resulting final parts.
65
     */
66
    protected function processParts(array $parts) : array
67
    {
68
        return [$this->partFactory->newContainerPart($parts)];
69
    }
70
}
71