DateConsumerService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 3
c 0
b 0
f 0
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A processParts() 0 3 1
A getPartForToken() 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 ZBateson\MailMimeParser\Header\IHeaderPart;
11
12
/**
13
 * Parses a date header into a Part\DatePart taking care of comment and quoted
14
 * parts as necessary.
15
 *
16
 * @author Zaahid Bateson
17
 */
18
class DateConsumerService extends GenericConsumerService
19
{
20
    /**
21
     * Returns a Part\LiteralPart for the current token
22
     *
23
     * @param string $token the token
24
     * @param bool $isLiteral set to true if the token represents a literal -
25
     *        e.g. an escaped token
26
     */
27 21
    protected function getPartForToken(string $token, bool $isLiteral) : ?IHeaderPart
28
    {
29 21
        return $this->partFactory->newToken($token, true);
30
    }
31
32
    /**
33
     * Constructs a single Part\DatePart of any parsed parts returning it in an
34
     * array with a single element.
35
     *
36
     * @param \ZBateson\MailMimeParser\Header\IHeaderPart[] $parts The parsed
37
     *        parts.
38
     * @return \ZBateson\MailMimeParser\Header\IHeaderPart[] Array of resulting
39
     *         final parts.
40
     */
41 21
    protected function processParts(array $parts) : array
42
    {
43 21
        return [$this->partFactory->newDatePart($parts)];
44
    }
45
}
46