Passed
Push — master ( 46ed75...ca2387 )
by Zaahid
03:33
created

IdHeader   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 34
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A getIds() 0 7 1
A __construct() 0 7 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;
9
10
use ZBateson\MailMimeParser\Header\Part\MimeLiteralPartFactory;
11
use ZBateson\MailMimeParser\Header\Consumer\IdBaseConsumerService;
12
13
/**
14
 * Represents a Content-ID, Message-ID, In-Reply-To or References header.
15
 *
16
 * For a multi-id header like In-Reply-To or References, all IDs can be
17
 * retrieved by calling {@see IdHeader::getIds()}.  Otherwise, to retrieve the
18
 * first (or only) ID call {@see IdHeader::getValue()}.
19
 *
20
 * @author Zaahid Bateson
21
 */
22
class IdHeader extends MimeEncodedHeader
23
{
24 90
    public function __construct(
25
        MimeLiteralPartFactory $mimeLiteralPartFactory,
26
        IdBaseConsumerService $consumerService,
27
        string $name,
28
        string $value
29
    ) {
30 90
        parent::__construct($mimeLiteralPartFactory, $consumerService, $name, $value);
31
    }
32
33
    /**
34
     * Returns the ID. Synonymous to calling getValue().
35
     *
36
     * @return string|null The ID
37
     */
38
    public function getId() : ?string
39
    {
40
        return $this->getValue();
41
    }
42
43
    /**
44
     * Returns all IDs parsed for a multi-id header like References or
45
     * In-Reply-To.
46
     *
47
     * @return string[] An array of IDs
48
     */
49 6
    public function getIds() : array
50
    {
51 6
        return \array_values(\array_map(
52 6
            function ($p) {
53 5
                return $p->getValue();
54 6
            }, \array_filter($this->parts, function ($p) {
55 5
                return !($p instanceof CommentPart);
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\Header\CommentPart was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
56 6
            })
57 6
        ));
58
    }
59
}
60