Test Failed
Push — 1.0.0 ( dd1332...30b11b )
by Zaahid
02:32
created

SignedMessage   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 42
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSignedMessageAsString() 0 12 3
A getSignaturePart() 0 7 2
1
<?php
2
3
namespace ZBateson\MailMimeParser;
4
5
/**
6
 * Description of SignedMessage
7
 *
8
 * @author Zaahid Bateson
9
 */
10
class SignedMessage extends Message
11
{
12
    /**
13
     * Returns a string containing the entire body of a signed message for
14
     * verification.
15
     *
16
     * @return string or null if the message doesn't have any children, or the
17
     *      child returns null for getHandle
18
     */
19
    public function getSignedMessageAsString()
20
    {
21
        $child = $this->getChild(0);
22
        if ($child !== null && $child->getHandle() !== null) {
23
            $normalized = preg_replace(
24
                '/\r\n|\r|\n/',
25
                "\r\n",
26
                stream_get_contents($child->getHandle())
27
            );
28
            return $normalized;
29
        }
30
        return null;
31
    }
32
33
    /**
34
     * Returns the signature part of a multipart/signed message or null.
35
     *
36
     * The signature part is determined to always be the 2nd child of a
37
     * multipart/signed message, the first being the 'body'.
38
     *
39
     * Using the 'protocol' parameter of the Content-Type header is unreliable
40
     * in some instances (for instance a difference of x-pgp-signature versus
41
     * pgp-signature).
42
     *
43
     * @return MimePart
0 ignored issues
show
Bug introduced by
The type ZBateson\MailMimeParser\MimePart 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...
44
     */
45
    public function getSignaturePart()
46
    {
47
        $contentType = $this->getHeaderValue('Content-Type', 'text/plain');
48
        if (strcasecmp($contentType, 'multipart/signed') === 0) {
49
            return $this->getChild(1);
50
        } else {
51
            return null;
52
        }
53
    }
54
55
}
56